After installing the Java JDK, start writing the first Java program--hello World. Used to output "Hello World" to the console. First, we use the original method of writing code with a text editor. In any one of the letter, take D packing directory as an example, in this directory to create a txt text, named HelloWorld, and then change the suffix to Java, that is, Helloworld.java.
Then open the edit code as follows:
Copy Code code as follows:
public class HelloWorld
{
public static void Main (String args[])
{
System.out.println ("Hello World");
}
}
After editing, save, then open the console with a DOS command to enter the D disk, enter the compile command "Javac", start compiling the Java source file Helloworld.java by entering the "Javac" JDK, and then generate the. class file.
Finally, to output "HelloWorld", to compile this. class file, enter "Java HelloWorld" in the console. As shown in figure:
This completes the first Java program, very simple. In fact, in order to facilitate learning, we'd better set up a special file under a disk to write Java programs, such as in the D disk to create a directory called "Java", and then write the program in this directory. It's best to start with text instead of an integrated development environment, such as Eclipse and so on, because it will exercise the ability to write code specifications.