Martin Preusse Martin Preusse - 1 year ago 169
Java Question

"duplicate entry" error when exporting Java project to JAR with Eclipse

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.

The error is

duplicate entry: some/class.class

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.

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


Answer Source

You could try modifying the line

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

in your build file to be

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

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.


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download