简体   繁体   English

Eclipse jar 导出和lib文件夹

[英]Eclipse jar export and lib folder

I've a java project that use some external jar library, when i export my project with eclipse (File-Export-Runnable Jar File), i select the option for "copy external libraries into a subfolder next to the main jar" and eclipse automatically create for me a folder named: I've a java project that use some external jar library, when i export my project with eclipse (File-Export-Runnable Jar File), i select the option for "copy external libraries into a subfolder next to the main jar" and eclipse自动为我创建一个名为:

myjarname_lib

I want to export the library in a folder named only lib, is it possible?我想将库导出到仅名为 lib 的文件夹中,可以吗? I've tried to rename the folder in lib but don't work, because the executable jar don't recognize the library in that folder.我试图重命名 lib 中的文件夹但不起作用,因为可执行文件 jar 无法识别该文件夹中的库。 How can i change the name of the external lib?如何更改外部库的名称?

Here is a workaround: When you run the Export wizard, there is a checkbox to create an Ant buildfile.这是一个解决方法:运行导出向导时,有一个复选框用于创建 Ant 构建文件。 Choose a location for the buildfile inside your project somewhere, then finish the export.在项目中的某处选择构建文件的位置,然后完成导出。 Open the buildfile that was created (you might need to hit "F5" to refresh the project).打开创建的构建文件(您可能需要按“F5”来刷新项目)。 Then just replace all "myprojectname_lib" with "lib".然后只需将所有“myprojectname_lib”替换为“lib”。 From then on, use "Run As -> Ant Build" for your exports instead of the Eclipse built-in.从那时起,使用“运行方式-> Ant 构建”进行导出,而不是内置的 Eclipse。

The drawbacks are that this buildfile is completely independent of your project and it seems to manage copying each dependency individually.缺点是此构建文件完全独立于您的项目,并且似乎可以单独管理复制每个依赖项。 If you change the dependencies of your project, you will have to manually update this file to get the correct exports.如果您更改项目的依赖项,则必须手动更新此文件以获取正确的导出。

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

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