[Java] Eclipse export JAR package

Ordinary classes export jar packages, which contain the main method and do not use other third-party jar packages.

1. Select the class or package you want to export in eclipse, right-click, and select the Export sub-option;

2. In the pop-up dialog box, select JAR file and click next;

3. Select the location and name of the jar package you want to generate in the text box behind the JAR file, pay attention to tick the boxes in front of Export generated class files and resources and Export java source files and resources, and click next;

4. Click the next button twice to reach the JAR Manifest Specification. Note that select the entry class of your jar package in the text box after Main class at the bottom. Click Finish to finish.

In the DOS environment, enter the directory where the jar package is located, run java -jar name.jar, and check whether the operation is correct.

 

If other jar packages are used in the exported program. For example, the database driver package oracl.jar.

1. First export the class to be exported according to the above steps to form a jar package, such as test.jar

2. Create a new folder main, such as in the root directory of the D drive;

3. Copy test.jar and oracl.jar to the main file, right-click test.jar, and extract it to the current folder. Cut META-INF\MANIFEST.MF to another place (eg desktop);

4. Right-click oracl.jar and extract it to the current folder.

5. In the DOS environment, go to the main folder of the D drive and execute jar cvfm new.jar meta-inf/manifest.mf . Don't forget the last point.

6. Open the newly generated new.jar with a compression tool, and overwrite the original new.jar with the META-INF\MANIFEST.MF you put on the desktop.

In the DOS environment, enter the directory where the JAR package is located, run java -jar name.jar, and check whether the operation is correct.

PS or install a plug-in named fatjar in eclipse, which can easily export projects containing third-party jar packages.

The original text comes from: http://www.cnblogs.com/lan0725/archive/2008/08/28/1873947.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327008783&siteId=291194637