Simple compilation of HelloJava. java files and precautions
Compile the HelloJava. java file:
- Public class HelloJava {
- /*
- 1. The source file ends with. java
- 2. The source file can contain classes declared by multiple classes.
- 3. The class can have the main method (that is, the main () method). The format is fixed: public static void main (String [] args ){}
- 4. The main () method is the program entry, and the method is the execution part of the program.
- 5. Only one public class can be declared in a source file, and the class name must be consistent with the source file name.
- 6. Each statement ends ";"
- 7. Execute the program: ① compile: After javac.exe is compiled, many. class bytecode files are generated. ② Run: java.exe
- 8. Multi-line comments cannot be nested
- */
- Public static void main (String [] args ){
- System. out. println ("Hello World! "+ '\ N' +" Hello kvoice! ");
- }
- }
- Class Person {
- // Defines another class
- }
- Class Hello {
- // Defines another class
- }
The development procedure is as follows:
① Write the Java code to the. java file;
② Use the javac command to compile the. java source file into a. class bytecode file;
③ Use java commands to generate the generated bytecode file. class;
Eg:
Run the following command:
Javac HelloJava. java
Java HelloJava