Java project exported as an executable jar package

Source: Internet
Author: User

1. Select the project you want to export.

For->export, choose Java in the following Jar File->next, select the path->next,finish you want to export.

2. Select the exported jar file to open with compressed file Manager

3. There is a Meta-inf folder, the inside of the MANIFEST.MF file dragged out. At this point the manifest file content should have only the following line:

</pre><pre code_snippet_id= "439185" snippet_file_name= "blog_20140731_2_9115505" name= "code" class= "HTML" ><span style= "FONT-SIZE:24PX;" > manifest-version:1.0</span>

4. Change the MANIFEST.MF. I changed the following content for example:

Manifest-version:1.0main-class:javamail. Javamailtest    Class-path:mail.jar

Main-class is followed by the class where the main function is located, and JavaMail is the package name.

Class-path is the external jar that is used in the back, and is separated by a space when there are multiple.

My Mail.jar and my own exported jar package are in the same folder, so no other path is written.

Note: Manifest-version,main-class,class-path followed by a colon, followed by a space , followed by the content. Always remember to use the carriage return at the end of each line. Contains the last row. That is, in my file, when the last close, the cursor position should be in the Class-path of the following line, on the safe side, you can also knock two spaces. (There is no reason why, the MANIFEST.MF file format is required = =)

5. Drag the modified MANIFEST.MF file back into the original jar and overwrite the original MANAFEST.MF.

6. The exported jar package can be executed,

e.g. command line input

Java-jar F:\tyqtest\AutoSend.jar



============== Cutting Line ======

later found that the method written above is very stupid, export the export as an executable package (runnable), and select the packages required libraries into generated jar (import the referenced external package to the generated jar package ) = = then you can.

Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

Java project exported as an executable jar package

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.