Get started with "Hello World" and helloworld

Source: Internet
Author: User

Get started with "Hello World" and helloworld

First, install jdk in Windows and input the following command in dos:

C: \ Users \ Administrator> java-version

Appears

Java version "1.6.0 _ 12"
Java (TM) SE Runtime Environment (build 1.6.0 _ 12-b04)
Java HotSpot (TM) Client VM (build 11.2-b01, mixed mode)

Indicates that the installation is successful;

Next, import the path of the program's execution file to the path environment variable,

Open dos again, go to *. java, and run the following command:

C: \ Users \ Administrator> cd E: \ Run script \ Java

C: \ Users \ Administrator> e:

E: \ Run the script \ Java>

Compile the source code *. java:

E: \ Run the script \ Java> javac Hello. java

After compilation, the *. class file is obtained and run:

E: \ Run the script \ Java> java Hello
Hello World!

Note: Java program statements

Public class Hello
{
Public static void main (String [] args)
{
System. out. println ("Hello World! ");
}
}

FAQs:

1. The. class suffix is included in the runtime.
If you try to use the following command E: \ Run the script \ Java> java Hello. class
The system will mistakenly believe that you are running a class file named class under the Hello package, and will go to the CLASSPATH of the system (usually including the current directory) to search for Hello. class. such a class does not exist, and it cannot exist because the class is a keyword and cannot be used as a class name.

2. Incorrect file name case
For systems like Windows, the Case sensitivity is not concerned during compilation. For example, when compiling Hello. java, you can also use:
E: \ Run the script \ Java> java hello. java
It can also be compiled, but the generated class file is still consistent with the source file: Hello. class.
Note the case sensitivity when running, for example, try to run the following command:
E: \ Run the script \ Java> java hello
An error similar to 1 will be reported:

E: \ Run the script \ Java> java hello
Exception in thread "main" java. lang. NoClassDefFoundError: hello (wrong name: He
Llo)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.