Eclipse Jar Packaging Details

Source: Internet
Author: User

Method/Step

In fact, packaging edlipse jar bag mainly catch 3 points is good:

First, the entry address is the class from which to run (certainly this class has the main function);

Second, the project relies on other jar package paths;

Finally, create a MANIFEST.MF file under the Eclipse Project, write the first two information into the file, and add the version number, which is explained in detail in the following steps.


Once you know the above 3 points, start detailing the packaging steps:

  1. 1. The demo engineering structure under Eclipse is shown, where Task.java is the main class of the current project run

  2. 2. The MANIFEST.MF file definition is as follows:

    manifest-version:1.0

    Main-class:com. Task

    Class-path:lib/dom4j-1.6.1.jar Lib/jaxen-1.1-beta-7.jar

    Attention:

    <1> MANIFEST.MF file The last line must be a blank line.

    <2> Lib/dom4j-1.6.1.jar and Lib/jaxen-1.1-beta-7.jar are separated by a space.

    <3> There is a space after each colon.

  3. 3. Eclipse Build Jar file Step (1)

    Select the class or package you want to export in Eclipse, right-click, select Export Sub-option

  4. 4. Eclipse Build Jar file Step (2)

    In the dialog box that pops up, select the Java file---Select the jar files

  5. 5. Eclipse Build Jar File Step (3)

    Select the location and name of the jar package you want to generate in the text box behind the jar file

  6. 6. Eclipse Build Jar file Step (4)

    Note the export generated class files and resources and export Java source files and resources in front of the tick

  7. 7. Eclipse Build Jar File Step (5)

    Select Manifest file

  8. 8. Place the generated Autoruntask.jar file and the Lib folder that holds the reference package in the same directory, and finally click on the generated jar file to run successfully.



This will be packaged and the introduction is complete.

If you want to run it, start the cmd window, find the path, run "Java-jar *.jar + Parameters" and you will see the results after the run.


The jar package can also be introduced later in other projects, but not just the main function of the portal, which is accessible to all class members, just like the Apache open source jar packages.

Eclipse Jar Packaging Details

Related Article

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.