For Java classes that are not in the package
For example Mywindow.java under the C:\Users\guoyan\Desktop directory
① first cut to the current directory
C:
CD C:\Users\guoyan\Desktop
② performing Javac Mywindow.java compilation
③ execute Java Mywindow run again
For Java classes in packages
Example: Hello.java in the C:\Users\guoyan\Desktop\Test directory, in the test package
① first cut to the current directory
C:
CD C:\Users\guoyan\Desktop\Test
② performing Javac Mywindow.java compilation
Compile and cut to upper-level directory (C:\Users\guoyan\Desktop\)
Cd..
③ execute Java Test.mywindow run again
You can also compile the Hello.java in the C:\Users\guoyan\Desktop\Test directory into a different folder
For example, compile to C:\Users\guoyan\Desktop\myclass (compile generated. class file in this directory)
① first cut to the current directory
C:
CD C:\Users\guoyan\Desktop\Test
② performing javac-d C:\Users\guoyan\Desktop\myclass Hello.java compilation
Compile and cut to C:\Users\guoyan\Desktop\myclass
CD C:\Users\guoyan\Desktop\myclass
③ Run
Java Test.hello
Jar Packaging Related commands
Typically, you need to package a compiled. class file to generate an executable file
① Write a configuration file
Arbitrarily name A. txt file, such as Config.txt
File contents:
Main-class:test.hello
(Note that there will be a space after the colon, and finally a newline to indicate the end of the file content)
② Cut to Directory (C:\Users\guoyan\Desktop\myclass)
Execute JAR-CVFM my.jar config.txt Test Package
Perform Java-jar My.jar operation
or double-click to run (double-click the case without the console, can only represent the graphical interface)
"Java Learning" Javac and Java commands