Prevent you from forgetting it every time you use it
1. Enter the path where the .java file is located

(cls clear console command )
2.javac compile

javac -d . demo1.java
javac demo1.java
such as The compiled file has a package name, javac -d . demo1.java

.class file will be generated in the cn/itcast/path path of the current path

If it is javac demo1.java command, the generated .class file is in the same directory as .java

3 .Run
java cn.itcast.path.demo1

without suffix.
The above is the detailed content of Example analysis of Java compiling and running in cmd. For more information, please follow other related articles on the PHP Chinese website!