Create an executable jar package and run

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.