简体   繁体   中英

packaging java code in eclipse

I have set up a java project in Eclipse and I want to put it in other machine, however my project has lots of dependencies in it. If I just copy and paste the project folder and add it to a different machine then it gives me a class path error and library error reference... what is the most efficient way of porting my code then with the source code to a different machine? does eclipse provides this feature?

  1. Right Click on the java project
  2. Select export
  3. Select the java node->runnable jar file then press next
  4. Select Java launch configuartion with which you have tested your app
  5. Select the third radio button Copy required into a sub folder next to generated jar ...
  6. press finish

lets say you chose c:\\temp\\myproject folder for output and your jar name is test.jar then the selected folder will have test.jar and a folder called lib containing all the supplier jars.... also the manifest of test.jar will have the classpath entry containing all the supplier jar path....

Manifest-Version: 1.0 Class-Path: . regx_lib/a.jar regx_lib/b.jar regx_lib/c.jar regx_lib/d.jar Main-Class: dcMain

Hope this will help....

虽然不是纯eclipse解决方案,但我喜欢使用maven来管理我的java应用程序和程序集插件的依赖关系,以便为我的用户/客户创建发行版(包括依赖项)。

The easiest way to create a basic project that you can 1-step copy-and-paste between machines is by setting up the project in a specific way:

1) Physically copy the dependency jars into the project folder, or a subfolder of the project folder:

替代文字

2) Right click the JARs and select "Build Path" -> Add to Build Path. 替代文字

This structure will let you copy the project to a new machine by simply copying the project folder. It is not the most scalable organization, and I encourage you to explore other options as your project grows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM