“重复条目"使用 Eclipse 将 Java 项目导出到 JAR 时出错 [英] "duplicate entry" error when exporting Java project to JAR with Eclipse

查看:43
本文介绍了“重复条目"使用 Eclipse 将 Java 项目导出到 JAR 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将带有 Eclipse 3.6.1 的 Java 项目导出到可运行的 Jar.这曾经可以正常工作但今天失败了,因为我在我的类路径中添加了一些额外的 Jars.

I am trying to exort a Java project with Eclipse 3.6.1 to a runnable Jar. This used to work properly but failed today, afer I added some additional Jars to my class path.

错误是

duplicate entry: some/class.class

有趣的是,我的构建路径中几乎所有的类都有一个重复的条目.即使我没有改变任何东西.我添加的 Jars 不包含重复的类.

Interestingly, there is a duplicate entry for almost any class in my buildpath. Even though I did not change anything. The Jars I added do not contain duplicate classes.

问题:这是某种 Eclipse 错误吗?我在看一些明显的东西吗?有没有人知道是什么导致了这个错误?

Question: Is this some kind of Eclipse bug? Am I ovrlooking something obvious? Does anybody have an idea what could cause this error?

干杯

推荐答案

您可以尝试修改该行

<jar destfile="/Volumes/resi/talosBase.jar" filesetmanifest="mergewithoutmain">

在你的构建文件中

<jar destfile="/Volumes/resi/talosBase.jar" filesetmanifest="mergewithoutmain" duplicate="preserve">

这将导致 ant 保留任何重复项的第一个条目并忽略其余条目.默认行为是添加",因此您最终可以得到多个具有相同完全限定名称的文件.此参数的另一个有效条目是失败",但我认为这对您没有帮助.

This will cause ant to preserve the first entry of any duplicate and ignore the rest. The default behavious is "add" so you can end up with multiple files of the same fully qualified name. The other valid entry for this paramter is "fail" but I don't think that will help you here.

旧答案

手动删除上次创建的可运行 jar 或更改生成的 ant 脚本,然后再创建新的 jar

Delete your last created runnable jar either manually or alter the generated ant script to do so before creating a new one

这篇关于“重复条目"使用 Eclipse 将 Java 项目导出到 JAR 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆