02-24-2011 07:12 PM
The following situation is causing a "Duplicate definition for class 'com.foo.MyClass'" error:
I have a number of .jar files built with the JDK javac tool (no Blackberry tools involved). I have manually combined those jar files into a single file called mylib.jar. One of the classes is called 'com.foo.MyClass' (not the real name of course).
In my Eclipse workspace, I have a project called MyLibWrapper, which is a library project which simply has mylib.jar on its class path, which is checked under "Order and Export". The goal is to generate a .cod file with the contents of mylib.jar.
There is a second project called MyApp. When I add the MyLibWrapper project to its class path (i.e. the "Projects" tab of "Java Build Path" in the project properties), I get the aforementioned error when I package the application (MyLibWrapper seems to package fine). However, if I instead build and package MyApp with MyLibWrapper.jar on the class path (i.e. the "Libraries" tab), everything works great--it builds, and runs perfectly fine in the simulator.
This last part makes me pretty sure that I have built mylib.jar correctly. I don't see any evidence in either mylib.jar or MyLibWrapper.jar that MyClass is defined multiple times. I've also made sure that SampleApp is not pulling in anything other than MyLibWrapper and the RIM API jar.
Any ideas? Am I missing something? It seems like it could be a bug in the Blackberry JDE. I'm using the 1.3.0 plugin on Eclipse 3.6.1, and compiling with the 184.108.40.206 SDK.
02-25-2011 03:16 AM
do you have persistant classes in your library? this is not supported on blackberry.
02-25-2011 12:28 PM
I'm not completely sure what you mean by persistent classes, but I'm pretty sure I don't have any. I'm only using the RIM API via net_rim_api.jar, and nothing implements Persistable.
I've also tested with one of the original libraries prior to repackaging into mylib.jar with the same results. And I neglected to mention that I'm running preverify.exe on the jar.
12-19-2011 05:01 PM
Same problem here. My application requires a library project that exports a jar. Packaging fails every time with 'Duplicate definition' for the first class in the jar. Anyone ever figure this out?
My rapc output looks like this:
-convertpng -quiet codename=deliverables\Standard\5.0.0\myApp deliverables\Standard\5.0.0\myApp.rapc
-sourceroot= C:\workspace\myApp\src; C:\workspace\myApp\res
0.0_220.127.116.11\components\lib\net_rim_api.jar; C:\workspace\myLibrary\deliverables\Standard\5.0.0 \myLibrary.jar C:\workspace\myLibrary\jar\thirdParty.jar C:\workspace\myApp\bin
12-20-2011 01:15 AM
When I got this error, it was because I wasn't setting up my dependencies correctly in the JDE. I was using someone else's JAR and was trying to add it as a dependency but I missed a step somewhere in the process. When I loaded it in properly, it worked like a charm. I was doing something different than what you are trying to do but I just thought I'd share this in case it gave you an insight for your purposes. Perhaps the problem is related to how you set up your project?
12-20-2011 12:59 PM
12-21-2011 06:21 AM
Well I believe I was trying to achieve something different than what you are. I was importing a JAR into my workspace as a library, and you are exporting a JAR.
These are the steps to import a JAR:
06-03-2012 09:33 PM