The Fat Jar Eclipse Plug-In is a Deployment-Tool which deploys an Eclipse java-project into one executable jar.
It adds the Entry "Build Fat-JAR" to the Export-Wizard.
In addition to the eclipse standard jar-exporter referenced classes and jars are included to the "Fat-Jar", so the resulting jar contains all needed classes and can be executed directly with "java -jar", no classpath has to be set, no additional jars have to be deployed.
Jars, External-Jars, User-Libraries, System-Libraries, Classes-Folders and Project-Exports are considered by the plugin.
The Main-Class can be selected and Manifest-files are merged.
The One-JAR option integrates a specialised Class-Loader written by Simon Tuffs ( [url]http://one-jar.sourceforge.net/[/url] ) which handles jar-files inside a jar.
Individual files and folders can be excluded or added to the jar.
Different settings can be stored and re-executed as "Quick Build" via the context-menu.
这里有一个使用方法简介,使用非常简单,如下:
Fat Jar Eclipse Plug-In Tutorial
Add the Class "demolib.DemoLib.java" containing the following code:
package demolib; |
The Project should look something like this:
Select "+ Build Fat Jar".
In the project properties add the Library "demolib/demolib_fat.jar" to the Java Build Path":
package demorun; |
The Project should look something like this:
Select "+ Fat Jar Exporter" and click "next >".
Click on the "Browse..." Button on the right side behind the Main-Class Edit field.
The FullyQualifiedName "demorun.DemoRunMain" is now set for "Main-Class".
In addition the file ".fatjar" storing the configuration settings has been created in the project root directory
The created jar file contains all classes from all referenced jar files (demolib_fat.jar) and the project classes.
This file can be executed anywhere, no classpath has to be set, because all necessary libraries
are extracted inside the "Fat Jar":
> java -jar demorun_fat.jar |