首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

fat jar高速打包工具

2012-08-02 
fat jar快速打包工具一款很好的打包工具,能把相关的第三方jar都打入进去Fat Jar Eclipse Plug-In Tutorial

fat jar快速打包工具
一款很好的打包工具,能把相关的第三方jar都打入进去
Fat Jar Eclipse Plug-In Tutorial

?

Step 1: Create a new Java Project "demolib"

Create a new Java Project named "demolib".
Add the Class "demolib.DemoLib.java" containing the following code:

?

Step 2: Create a jar file using Fat Jar Plug-In

In the "Package-Explorer" (not the "Resource-View") right click on the project "demolib".
Select "+ Build Fat Jar".

fat jar高速打包工具

A Configuration Dialog appears. Just press "Finish".

fat jar高速打包工具

The File "demolib_fat.jar" has been created in the project root directory.

fat jar高速打包工具

?

Step 3: Create a new Java-Project "demorun"

Create a new Java Project named "demorun".
In the project properties add the Library "demolib/demolib_fat.jar" to the Java Build Path":

fat jar高速打包工具

?

Step 4: Create Main Class

Add the Class "demorun.DemoRunMain.java" containing the following code:

?

Step 5: Start the Build Fat Jar Dialog

Start the Export Wizard from the File-Menu ("File" -> "Export").
Select "+ Fat Jar Exporter" and click "next >".

fat jar高速打包工具

Select the project "demorun" and click "next >".

fat jar高速打包工具

A Configuration-Dialog appears showing the current Settings.

fat jar高速打包工具

?

Step 6: Select the Main Class

The Main Class - the one containing the static methode main - must be defined in the jar.
Click on the "Browse..." Button on the right side behind the Main-Class Edit field.

fat jar高速打包工具

Select "DemoRunMain" and click the "OK" Button.
The FullyQualifiedName "demorun.DemoRunMain" is now set for "Main-Class".

?

Step7: Finish

Save the current Settings by clicking on the "Finish" Button.

fat jar高速打包工具

The File "demorun_fat.jar" has been created in the project root directory.
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对应linux下执行的shell脚本:#!/bin/bashCLASSPATH=/home/jdk1.6.0_31/lib:/home/jdk1.6.0_31/jre/lib:$CLASSPATH#runcd /home/ytbparserjava -jar ytb-parser.jar

热点排行