在Eclipse使用插件将java程序打包成jar
2009-04-10 12:59
876 查看
插件下载地址 :
http://sourceforge.net/project/showfiles.php?group_id=115990&package_id=125924
插件的安装与启动:
zip文件含有插件目录的,把fatjar.jar放入eclipse的插件目录下.
关闭 eclipse.
以eclipse -clean命令从命令行启动 eclipse
否则发现不了插件.
删除:
只要在eclipse的插件目录下移出net.sf.fjep.fatjar_x.x.x即可
实践:
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:
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 chosen operation is not currently available” 的错误,将jdk升级或下载插件的时候选择较老的版本即可。这属于兼容性问题。
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:
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":
http://sourceforge.net/project/showfiles.php?group_id=115990&package_id=125924
插件的安装与启动:
zip文件含有插件目录的,把fatjar.jar放入eclipse的插件目录下.
关闭 eclipse.
以eclipse -clean命令从命令行启动 eclipse
否则发现不了插件.
删除:
只要在eclipse的插件目录下移出net.sf.fjep.fatjar_x.x.x即可
实践:
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"); } } |
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 chosen operation is not currently available” 的错误,将jdk升级或下载插件的时候选择较老的版本即可。这属于兼容性问题。
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(); } } |
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 |
相关文章推荐
- 如何把使用命令行或者Eclipse将Java程序打包为jar文件
- 如何使用matalb中的deploytool函数打包jar包嵌入eclipse供java程序调用
- 使用eclipse打包Java程序jar文件
- 使用jar命令打包java程序
- 使用fat.jar插件+exe4j将Java工程生成exe程序
- 使用jar命令对java程序进行打包
- java开发环境eclipse的使用(模块代码折叠、可视化开发插件、生成Jar插件)
- 使用 maven 插件 maven-shade-plugin 对可执行 java 工程及其全部依赖 jar 进行打包
- 使用Eclipse把java文件打包成jar 含有第三方jar库的jar包
- Java程序打包成jar文件(并使用bat格式的档执行jar包)
- 如何在eclipse中把java程序打包成jar包?
- 使用eClipse将java源码打包成jar包
- 在Eclipse下Java程序打包成jar文件
- 使用 maven 插件 maven-shade-plugin 对可执行 java 工程及其全部依赖 jar 进行打包
- JAVA 打包)Eclipse插件FatJar安装与使用
- 将eclipse java程序打包成jar的总结(包括工程中没有引用外部jar包和有引用外部jar包两种情况)
- java中如何制作可双击执行的程序--jar打包工具的使用
- 将eclipse java程序打包成jar的总结(包括工程中没有引用外部jar包和有引用外部jar包两种情况)
- 如何使用Eclipse将包含第三方jar库的java工程打包成jar包
- java中如何制作可双击执行的程序--jar打包工具的使用