External JAR problems on BlackBerry projects under Eclipse

I've been recently trying to parse some external XML's and for this I wanted to user the KXML2 library. But I came across a pretty nasty problem.
To be able to use this library you obviously need to add the jar file on your project. Everything ok until BlackBerry signals that it couldn't find the jar file specified. I wasn't the only one with this problem (see http://www.thinkingblackberry.com/archives/204) so it wasn't something I did wrong.
Anyway, there's a simple solution for this shortcoming. Here are the steps:
1. Download the jar file
2. Preverify the .jar file
This can be done from the command line. Before this, be sure you have java set in your environment variables (in my case “C:\Program Files\Java\jdk1.6.0_20\bin”). Now, copy your .jar file in JDE_HOME/bin and run the following command:
- preverify.exe -classpath ..\lib\net_rim_api.jar your_jar_file_name.jar
Where JDE_HOME is the BB JDE home directory or the component pack home directory. The “preverify” command will generate the file in the “output” folder in JDE_HOME/bin.
3. Add the .jar to your project
Create a lib folder in your project, copy the preverified .jar file in there. Right-click on your project, go to “Properties” → “Java Build Path” → “Libraries” tab → “Add JARs”, select the preverified .jar file that you've just copied in the lib folder, click and “OK”. Now, while in “Properties” window, go to “Order and Export” tab and check the newly added .jar. Click “OK” and you should be done.
Category: BlackBerry



Discussion
Hi,
I did the same as is in this blog but when I try to use the packages of the jar I got error that this package does not exist.
Can you explain why this happens?
Waiting for ur reply.
Hey Hira, sorry for the late response. So you followed all the instructions and still the error?
Have you loaded the preverified jar?
Are u sure export is needed ?
when you wrote :
Now, while in “Properties” window, go to “Order and Export” tab and check the newly added .jar. Click “OK” and you should be done.
regards
--
http://rzr.online.fr/q/j2me
I'm trying to get the same effect using just ant and bb-ant-tools.
All well and fine up to the point where I want to produce the final jar/cod files (that has everything, including the library jar code) included.
Exactly what dark magic does that "Export" thing in eclipse activate? I just can not seem to get the library code in to the compiled cod files...
Hmm...the folling link suggests it should be possible simply by adding the (preverified) jar to the src input
http://supportforums.blackberry.com/t5/Java-Development/Adding-External-Jars-using-eclipse/td-p/86463
Hi,
I tried to fix it the way you mentioned me but i still get an error. In CMD i get the following error:
"JAR file creation failed with error -1
The preverified classes if any are in tmp19600. See jar log of errors in output\jarlog.txt"
When i open \output\jarlog.txt i see the following message:
"Error: No such file or directory
jar -cfm "output\WS.jar" tmp19436\\META-INF\MANIFEST.MF -C tmp19436 . "
I opened the folder tmp19600 and i can see the classes (just plain classes not a .jar file) there but they have some scrambled code inside and when i'm trying to import them to the package i can't see or use them in Eclipse.
Can you please help me with this issue if you know how? Help will be much appriciated.
Thank you in front,
Alex
Leave a Comment :
Leave a Comment