To compile a java program, you need to use the javac command. The usage method is: 1. Open the command prompt and enter the directory where the Java file is located; 2. Execute the [javac file name.java] command and press Enter. At this time, a class file will be generated in the directory where the Java file is located.
#You need to use the javac command to compile a java program.
(Recommended learning: java introductory program)
Related introduction:
How to compile a java program through the javac command?
1. Open cmd and enter the folder where the .Java file is located.
Since my source files are in the JAVA folder of the D drive, I need to enter the D drive first (enter d: Enter)
2 , enter the D drive, and then enter the JAVA folder. After entering cd JAVA
, press the Enter key.
3. Enter the javac random.java
command and press the Enter key to compile the program.
(Video tutorial recommendation: java video tutorial)
The compilation is completed. You can see that a .class file is generated in the directory where the .java file is stored.
4. At this time, execute the java random
command to run the program.
The above is the detailed content of What command do you need to use to compile a java program?. For more information, please follow other related articles on the PHP Chinese website!