Java Project hit jar package

Source: Internet
Author: User

Java Project hit jar package is divided into 2 cases:

One, the Java project does not import third-party jar packages

It's easier to pack at this time:

1. First open the project in Eclipse, right click on the project, select "Export";
2. Select Java/jar File,next;
3. Select the resources to export you can choose the project folder you want to include, some unnecessary folders do not need to put in, so as not to increase the space;
here are a few options:
* Export generated class files and resources means that only the generated. class file and other resource files are exported
* Export all output folders for checked projects means all folders for the selected item are exported
* Export Java source file and resouces means the exported jar package will contain your source code *.java, if you do not want to leak the source, then do not choose this
* Export refactorings for checked projects contains some of the reconstructed information files.
Select the path to the exported jar in the Select the export destination, Next
4. On the next page, you can choose whether to export *.class files that contain warning warning or error errors. Generally, don't worry about him, Next.
5. The next page can be configured for the project. (If the project does not introduce a third-party jar package, this is the system default option for Ok,main class must be set to be the Main method entry class for your project)
* Generate The manifest file is the system to help us automatically generate MANIFEST.MF files, if your project does not reference other Class-path, then you can choose this.
* Use existing mainfest from workspace. This is optional and we can customize it. MF file, formatted as above.
* Seal content. To encapsulate the entire jar or the specified package packet
* Main class. Here you can choose your program portal, the future packaging of the jar is your entry class execution results.
final finish, done. ......

Second, Java project has imported third-party jar package (for example, the project has imported Sqlserver2005.jar package)

Packing is a bit more complicated at this time:

The previous 4 steps are the same as above, but the 5th step is to select the use existing mainfest from workspace option, and select a MANIFEST.MF file you created yourself because the default selection is generate the Manifest the file option, which does not use a third-party jar package for the project to penetrate into the jar package generated by the Java project.

Custom configuration file MANIFEST.MF:

First create a manifest.mf file in the root directory of the project

Next, open the file with Notepad and edit:

For example:
manifest-version:1.0
Span style= "color: #ff99cc;" >main-class:studentmanager_test
class-path:sqlserver2005.jar

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.