An application is made into an executable jar package to publish the application through a jar package.
The key to creating an executable jar package is to have the Java-jar command know which class in the jar package is the main class,
The Java-jar command can run the program by running the main class.
Note: When creating a jar package, all classes (that is, the class file) must be placed in the directory structure corresponding to the package structure
1. Select the directory you want to package
You want to package the class file directory day and the file directory that the program needs to call plane
Day11 is the package name of the client class, which holds the Client.class
2. Go to the path of the pre-packaged directory (note: To package the previous layer path of the directory)
C:\users\fek>g:
G:\>CD G:\eclipse_java_projects\testJAR_01
G:\eclipse_java_projects\testjar_01>
3. Create the executable jar file and display the compression process:
Jar Cvfe Testjar.jar Day11. Client Day11 plane
The result is the directory that holds the class file under the current path Day11 and
The program needs to call the directory of the file plane (the directory must be selected correctly, do not select into a previous level directory) packaged into a jar package, and specify the use of Day11. Client class
(If the main class has a package name, you must specify the full class name here) as the entry for the program.
4. Run the above executable jar package
1. Using Java commands,
G:\eclipse_java_projects\testjar_01>java-jar Testjar.jar
2. Using the JAVAW command, the syntax for using the JAVAW runtime is: JAVAW Testjar.jar
(the command may not be available, so it is recommended to run the jar package with the first command)
Create an executable jar package and run