使用 Eclipse 在清单文件中构建 ClassPath 变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4432440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Building ClassPath variable in Manifest file with Eclipse
提问by stevebot
Is there a way for Eclipse to output all the Jars I would like to define on my ClassPath variable in the Manifest when exporting a project as a jar? I would like to be able to just click on all the jars I need my project to depend on, and then have Eclipse output it all like:
当将项目导出为 jar 时,Eclipse 有没有办法输出我想在 Manifest 中的 ClassPath 变量上定义的所有 Jars?我希望能够点击我需要我的项目依赖的所有 jars,然后让 Eclipse 输出它,就像:
ClassPath: . /lib/somejar.jar /lib/otherjar.jar
Thanks
谢谢
回答by mhaller
Yes, there is:
就在这里:
Eclipse > File > Export > Java > Runnable JAR File > "Copy required libraries into a sub-folder next to the generated JAR".
Eclipse > 文件 > 导出 > Java > 可运行 JAR 文件 >“将所需的库复制到生成的 JAR 旁边的子文件夹中”。
It will create a MANIFEST.MF with all the classpath entries of your Java project. You need to have a working launch configuration.
它将使用 Java 项目的所有类路径条目创建一个 MANIFEST.MF。您需要有一个有效的启动配置。
Do notuse "Package required libraries", as it will create a nasty Jar-In-Jar-ResourceLoader class into your jar file. You usually don't want such things in there.
千万不能使用“包所需的库”,因为它会创建一个讨厌的将罐中,将罐的ResourceLoader类到您的jar文件。你通常不希望在那里有这样的东西。
Btw, did you try Maven? It does that for you automatically. Every time. On all platforms. On all IDEs. Independently of your Eclipse version. It does that also on your build server when you're on holiday.
顺便说一句,你试过Maven吗?它会自动为您执行此操作。每次。在所有平台上。在所有 IDE 上。独立于您的 Eclipse 版本。当您度假时,它也会在您的构建服务器上执行此操作。