如何在 Eclipse 中使用 jardesc?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7462282/
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
How to use jardesc in Eclipse?
提问by maaartinus
I want to create an executable JAR-file from my eclipse project. It references other projects, which also reference other projects (and so on) and some JAR files.
我想从我的 eclipse 项目创建一个可执行的 JAR 文件。它引用了其他项目,这些项目也引用了其他项目(等等)和一些 JAR 文件。
According to this answer, everything should go "within 2 clicks". But not for me:
根据这个答案,一切都应该“在 2 次点击内”。但不适合我:
It reports a warning:
它报告警告:
Problem writing mg/build/classes/META-INF/MANIFEST.MF to JAR: duplicate entry: META-INF/MANIFEST.MF duplicate entry: META-INF/MANIFEST.MF
将 mg/build/classes/META-INF/MANIFEST.MF 写入 JAR 时出现问题:重复条目:META-INF/MANIFEST.MF 重复条目:META-INF/MANIFEST.MF
It looks like it tries to include existing manifests from all projects, which simply doesn't make sense. I actually do not want to include any of them, just to generate a new one. I haven't found any way to switch it off. OK, it's just a warning.
看起来它试图包含来自所有项目的现有清单,这根本没有意义。我实际上不想包含其中任何一个,只是为了生成一个新的。我还没有找到任何关闭它的方法。好吧,这只是一个警告。
It looks like I need to manually take care of all the referenced jar files... actually, Eclipse knows them, I do not.
看起来我需要手动处理所有引用的 jar 文件......实际上,Eclipse 知道它们,我不知道。
I need to either include the content of all the referenced jar files or to copy all of them into the target folder and list them in the Manifest. I've got no idea how to do it.
我需要包含所有引用的 jar 文件的内容,或者将它们全部复制到目标文件夹中并在 Manifest 中列出它们。我不知道该怎么做。
I also wonder if the jardesc file is usable from ant build scripts.
我还想知道 jardesc 文件是否可以从 ant 构建脚本中使用。
采纳答案by RobertG
I got the same error message ("duplicate entry") when, in my case
在我的情况下,我收到了相同的错误消息(“重复条目”)
- I checked the option to include an existing manifest file.
- AND I specified to include MANIFEST.MF among the files to be included in the .jar.
- 我选中了包含现有清单文件的选项。
- 并且我指定在要包含在 .jar 中的文件中包含 MANIFEST.MF。
Once I excluded MANIFEST.MF in the "Select the resources to export:" file tree of the jar generation wizard, the warning disappeared.
一旦我在 jar 生成向导的“选择要导出的资源:”文件树中排除了 MANIFEST.MF,警告就消失了。
As for including referenced projects with your jar, I recommend making them into jar files as well, and including those in the project you want to make a jar of.
至于在 jar 中包含引用的项目,我建议也将它们制作成 jar 文件,并将那些包含在您想要制作 jar 的项目中。
Then, make sure to set the manifest's classpath correctly.
然后,确保正确设置清单的类路径。