Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
575 views
in Technique[技术] by (71.8m points)

"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?

Cheers

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


OLD-Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...