分享

Eclipse打可执行JAR包 - 插件FatJar安装与使用

 9loong 2010-05-28
http://blog.csdn.net/jikeyzhang/archive/2009/10/27/4731968.aspx

下载RUL: http://fjep./
下载fatJar插件,解压缩后是一个.../plugins/(net...)把 plugins下面的(net..)文件夹拷贝到eclipse的plugins下,重新启动Eclipse3.1,Windows=> prefernce=>fat jar preference看到他就说明已经安装成功了。
如果没有看到,没有关系,删除D:\eclipse310\configuration \org.eclipse.update\platform.xml文件(此文件可以自动生成)不用担心以前的插件会因此而消失,没事。

使用方法:你的项目=〉Export..=>FatJar.

( fatJar这插件打包的时候可把用到的第三方的JAR包也一起打到目标JAR中。 )

【图解】

 

      开始:在你的工程项目里右键弹出下图:

然后Buile Fat Jar出现下图:

    

再然后就Next了,又出现下图:

再然后就没了。在桌面上找到刚刚打包的libr.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:

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 "+ 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 demorun_fat.jar
            Hello
            

 
(#)


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多