eclipse 打包插件

 

source:http://fjep.sourceforge.net/fjeptutorial.html

http://fjep.sourceforge.net/#inst

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:

package demolib;

public class DemoLib {
    public static void sayHello() {
        System.out.println("Hello");
    }
}

The Project should look something like this:


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 "Fat Jar > Quick Build Fat Jar"

A Configuration Dialog appears. Just press "Finish".

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


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":


Step 4: Create Main Class

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

package demorun;

import demolib.DemoLib;

public class DemoRunMain {
    public static void main(String[] args) {
        DemoLib.sayHello();
    }
}

The Project should look something like this:


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 >".

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

A Configuration-Dialog appears showing the current Settings.


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.

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.

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 deomrun_fat.jar
Hello

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值