Compile HelloWorld.java program
In the dos command line, enter the directory java source files, use the javac
command to compile
the command:
javac java source file name.java
For example:
javac HelloWorld.java
After the compilation is successful, there is no prompt on the command line. Open the directory of the source file and find that a new file HelloWorld.class is generated. This file is the compiled file, which is the executable file of java, called the bytecode file , there is With the bytecode file, you can run the program.
Run the HelloWorld program
In the dos command line, enter the root directory of the java source file and use the java command to run.
command
java 类名字
For example
java HelloWorld
java HelloWorld don't write don't write don't write class
The compiled code is:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("HelloWorld");
}
}
supplement
Just write the code in Notepad, and then change the file suffix to .java