简体   繁体   English

在eclipse中打包java代码

[英]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. 我在Eclipse中设置了一个java项目,我想将它放在其他机器中,但是我的项目中有很多依赖项。 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? eclipse提供此功能吗?

  1. Right Click on the java project 右键单击java项目
  2. Select export 选择export
  3. Select the java node->runnable jar file then press next 选择java node->runnable jar file然后按next
  4. Select Java launch configuartion with which you have tested your app 选择用于测试应用程序的Java launch configuartion
  5. Select the third radio button Copy required into a sub folder next to generated jar ... 选择第三个单选按钮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.... 假设您选择c:\\temp\\myproject文件夹进行输出,并且您的jar名称为test.jar然后所选文件夹将包含test.jar和一个名为lib的文件夹,其中包含所有供应商jar ....还有test.jar清单test.jar将包含包含所有供应商jar路径的类路径条目....

Manifest-Version: 1.0 Class-Path: . 清单 - 版本:1.0类路径:。 regx_lib/a.jar regx_lib/b.jar regx_lib/c.jar regx_lib/d.jar Main-Class: dcMain 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: 1)将依赖项jar实际复制到项目文件夹或项目文件夹的子文件夹中:

替代文字

2) Right click the JARs and select "Build Path" -> Add to Build Path. 2)右键单击JAR并选择“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. 它不是最具扩展性的组织,我鼓励您在项目发展过程中探索其他选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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