--To know the reason why
1, when we are accustomed to the various IDE tools to write Java program code, do not know what they did for us! First write the source code with the simplest text tool (if the JDK is already installed and the environment variable is configured).
Cases:
1.1 Editing the source code
Create a new directory work in the C drive and create a new text file Helloworld.java such as
Helloworld.java content (source code):
Public class HelloWorld { publicstaticvoid main (string[] args) { System.out.println ("Hello world!" ); }}
1.2 Compiling into class file
Start Menu "Run" input cmd enter open Window console
Input cd/work switch to Java source directory
Enter Javac Helloworld.java Compile the source code, such as
There is no prompt to compile correctly, but the Helloworld.class file is generated in the work directory
1.3 Running Java programs
Once the compilation is complete, you can run the program! In the console you just entered Java HelloWorld Run (note: The Helloworld.class file is running, but "do not" enter the extension. Class), such as
When we use IDE tools to write source code, such as Eclipse. When we save the source code or create a Java file, eclipse will automatically compile the source into a class file (called Javac compilation). When we are running a single run, it is equivalent to calling the Java command to execute the program.
Extension 1: How to display file name extensions
How to display the file extension: Double-click Computer Tools Folder Options View tab remove the check box in front of "hide extensions of known types", such as (set, you can see the file extension!). such as TXT)
Time: January 12, 2016 20:22:49
Compilation and operation of a Java