使用 Eclipse 进行 JAR 时是什么导致“重复输入”警告?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9108124/
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
What causes "duplicate entry" warnings when JAR'ing with Eclipse?
提问by H2ONaCl
I am jar
ing my Java Swing application which also uses joda.time
, apache.commons
and a few other external jar
s.
我正在运行jar
我的 Java Swing 应用程序,它也使用joda.time
,apache.commons
以及其他一些外部jar
s。
The output jar
runs, however, Eclipse did report some warnings while producing the jar
via Export > Java > Runnable Jar. I am choosing the "repackage" option for dealing with the external jar
s. Here's the top of the listing of about 146 lines of warnings.
输出jar
运行,但是,Eclipse 在生成jar
via Export > Java > Runnable Jar时确实报告了一些警告。我正在选择“重新打包”选项来处理外部jar
s。这是大约 146 行警告列表的顶部。
JAR export finished with warnings. See details for additional information.
Details:
duplicate entry: allclasses-frame.html
duplicate entry: allclasses-frame.html
duplicate entry: allclasses-noframe.html
duplicate entry: allclasses-noframe.html
duplicate entry: constant-values.html
duplicate entry: constant-values.html
duplicate entry: deprecated-list.html
duplicate entry: deprecated-list.html
duplicate entry: help-doc.html
duplicate entry: help-doc.html
duplicate entry: index-all.html
duplicate entry: index-all.html
duplicate entry: index.html
duplicate entry: index.html
duplicate entry: overview-frame.html
duplicate entry: overview-frame.html
duplicate entry: overview-summary.html
duplicate entry: overview-summary.html
duplicate entry: overview-tree.html
duplicate entry: overview-tree.html
duplicate entry: package-list
duplicate entry: package-list
duplicate entry: resources/inherit.gif
duplicate entry: resources/inherit.gif
As this is a Swing application for the desktop, warnings about html
and css
(not shown) are quite unexpected. Advice?
由于这是一个用于桌面的 Swing 应用程序,关于html
和css
(未显示)的警告是非常出乎意料的。建议?
回答by Thilo
This looks like the jar files include Javadocs. The duplicate entries will somehow clobber that. However, unless you need the Javadocs, you don't need to care. Try to get jar files without sources or docs, though.
这看起来像 jar 文件包含 Javadocs。重复的条目会以某种方式破坏它。但是,除非您需要 Javadoc,否则您无需关心。不过,请尝试获取没有源代码或文档的 jar 文件。
Also, Eclipse has an option to include dependency jars as jars (rather than throwing all their contents together). You can try that, too.
此外,Eclipse 可以选择将依赖项 jar 包含为 jar(而不是将它们的所有内容放在一起)。你也可以试试。
回答by nullromo
For me, I had my main method in XXX.java
and moved it to YYY.java
, so my run configuration was still set up to use XXX
as the main entry point. At the bottom of all the duplicate entry: blahblahblah
messages, there was one that said something like unable to locate main class
. So I just changed my run configuration and all the errors went away.
对我来说,我有我的 main 方法XXX.java
并将它移动到YYY.java
,所以我的运行配置仍然设置为XXX
用作主要入口点。在所有duplicate entry: blahblahblah
消息的底部,有一个说类似的话unable to locate main class
。所以我只是改变了我的运行配置,所有的错误都消失了。
回答by Charles Mosndup
I solved the problem by clicking "Package required libraries into generated JAR" in the Runnable JAR Specification of the Runnable JAR File Export dialog, instead of the default "Extract required libraries into the generated JAR".
我通过单击 Runnable JAR File Export 对话框的 Runnable JAR Specification 中的“Package required libraries into generated JAR”解决了这个问题,而不是默认的“Extract required libraries into the generated JAR”。
Eclipse IDE for Java Developers Version: Luna Service Release 2 (4.4.2) Build id: 20150219-0600
适用于 Java 开发人员的 Eclipse IDE 版本:Luna Service Release 2 (4.4.2) 构建 ID:20150219-0600
回答by kike
It's not true.
这不是真的。
The thing is that you are exporting to a jar file, extracting classes from referenced libraries(Jar library that you uses).
问题是您要导出到jar 文件,从引用的库(您使用的 Jar 库)中提取类。
And, when eclipseextracts every thing contented in the jar files overwrite the different objects with the same name and path.
并且,当Eclipse提取 jar 文件中包含的所有内容时,会覆盖具有相同名称和路径的不同对象。
I've got the same problem, and i'm looking for a solution, because you can 'package' the jars into the jar but it's a slower runable solution.
我遇到了同样的问题,我正在寻找解决方案,因为您可以将罐子“打包”到罐子中,但这是一个运行速度较慢的解决方案。
Luck
运气