1 Reply Latest reply on May 28, 2010 6:32 PM by 843851

    BouncyCastle Files not found at Runtime

      I am trying to do encryption/decryption using
      bouncycastle. At compile time, there is no
      problem but when I run the J2ME emulator, I get
      the error:
      java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1InputStream: Cannot create class in system package

      Line of code:

                InputStream in = getClass().getResourceAsStream("/public.key");
                ASN1InputStream aIn = new ASN1InputStream(in);

      I created a directory called lib under my J2ME project root directory
      and I included the files cldc_classes.jar and cldc_crypto.jar
      and those classes are in my build path. I am using Java 5 and WTK 2.5
      with proguard 4.4 and Eclipse GANYMEDE as IDE.

      Any help will be greatly appreciated.


        • 1. Re: BouncyCastle Files not found at Runtime
          Okay, I finally figured out the solution to this problem. The bouncy castle jars contain some classes in the java.* package like BigInterger, SecureRandom, etc and these classes are being confused with the regular java.* system packages. So what I did was rename the java.* packages in the bouncy castle files to my own package like simpaq.* and everything worked just fine. I hope this helps someone.