5 Replies Latest reply: Nov 13, 2012 11:33 AM by safarmer RSS

    Java Card program execution on Eclipse

    973620
      Hi Dears,

      I am new to Java Card. I did setup to run Java Card programs on eclipse using http://eclipse-jcde.sourceforge.net/.

      This is my simple program below

      import javacard.security.RandomData;

      public class Main {

           public void main() {
                                    
                RandomData rd = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
                
                short outLen = 10;
                byte buffer[] = new byte[outLen];
                short outOffset = 0;
                          
                rd.generateData(buffer, outOffset, outLen);

           }

      }

      Compilation is successful but when I run the program I get the following error.

      Error occurred during initialization of VM
      java/lang/NoClassDefFoundError: java/lang/String

      This is very annoying. I think my run time environment is not ok for running java card programs. I am able to run Java programs but not java card programs. Any one can help please?

      Thanks,

      Regards,
      Naveed
        • 1. Re: Java Card program execution on Eclipse
          973833
          Hello,

          class String is not available on Java cards, for a first applet you should try with an example from a tutorial (and no main for applets)

          Gilles
          • 2. Re: Java Card program execution on Eclipse
            safarmer
            please post code with {code} tags
            Naveed86 wrote:
            Hi Dears,

            I am new to Java Card. I did setup to run Java Card programs on eclipse using http://eclipse-jcde.sourceforge.net/.

            This is my simple program below
             
            import javacard.security.RandomData;
            
            public class Main {
            
                 public void main() {
                                          
                      RandomData rd = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
                      
                      short outLen = 10;
                      byte buffer[] = new byte[outLen]; 
                      short outOffset = 0;
                                
                      rd.generateData(buffer, outOffset, outLen);
            
                 }
            
            }
            Compilation is successful but when I run the program I get the following error.

            Error occurred during initialization of VM
            java/lang/NoClassDefFoundError: java/lang/String

            This is very annoying. I think my run time environment is not ok for running java card programs. I am able to run Java programs but not java card programs. Any one can help please?

            Thanks,

            Regards,
            Naveed
            • 3. Re: Java Card program execution on Eclipse
              safarmer
              How do you run your application? Have you loaded onto a card or emulator?

              - Shane
              • 4. Re: Java Card program execution on Eclipse
                973620
                I am running on Eclipse.
                • 5. Re: Java Card program execution on Eclipse
                  safarmer
                  Hi,

                  The JC API jar files do not have a real implementation as it is provided by the JCRE. You need to load the file as an applet onto an emulator or a real card. Then the only way to interact with the code is through APDU's.

                  You could implement stub/dummy implementations for the JC API if you want to run as a unit test though.

                  - Shane