Question

I'm currently working with J2me by Mobile Tools for Java (MTJ) on Eclipse. My program need to encrypt SMS messages by RSA so i try to use bouncycastle library. I download bouncycatle version 1.47 and add to to my buildpath. No problem occurs when building project. But when i try to run on emulator, i get this error:

TRACE: <at java.lang.NoClassDefFoundError: org/bouncycastle/crypto/engines/RSAEngine>, startApp threw an Exception

It's a common problem, NoClassDefFound. To solve this, i know i must include the class file of bouncycastle in classpath. But here come the problem, i cant pack bouncycastle class file into the jar which MTJ created. For regular project, all i need to do is tick on the checkbox in "Order and Export" tab to have all class files in the "ticked" referenced library packed in to output jar. I do the same here but after i create package, i check the new jar file and no class of bouncycastle is inside (check using WinRar).I did some I'm using Eclipse Indigo Release 2, build-id: 20120216-1857, MTJ version 1.1.2. I also tried to create package by eclipse Pulsar 1.3.1 but the problem still persists. Is there any suggestion? is this a bug?

Regards.

Was it helpful?

Solution

"Order and Export" is not working as you think it is. If you have two projects - ProjectA and ProjectB and ProjectA dependends on ProjectA, then if ProjectA needs some.jar and you find out that ProjectB needs some.jar too, then "Order and Export" for that jar in ProjectA makes it "visible" also for ProjectB.

For JAR files you cannot add another jar into the JAR files (it works for WARs and EARs). There are two possibilities how to solve this

  1. you can unzip required JAR and add class files to your jar, jar -u can help you (this seems difficult, but if you are using ant or maven you will configure that once)
  2. you can try to use MANIFEST headers
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top