3 Replies Latest reply on Mar 17, 2017 9:02 AM by Intel Corporation

    Intel Edison MRAA Java error

    jakelstr

      Hello,

      I recently got an Intel Edison here at work and I've been playing around with it. I'd like to write code in Java because I'm more familiar with it. (I haven't been able to get the Eclipse IDE to work for some unknown reason but that's not why I'm posting.)

       

      I'm trying to compile this simple Java file on the Edison:

      import mraa.Dir;
      import mraa.Gpio;
      import mraa.IntelEdison; 
      import mraa.mraa; 
      import mraa.Platform;
      import mraa.Result; 
      
      
      public class HelloEdison
      {
          static
          {
              try
              {
                  System.loadLibrary("mraajava");
               }
              catch (UnsatisfiedLinkError e)
              {
                  System.err.println("Blah \n" + e);
                  System.exit(1); 
              }
          }
          
          public static void main(String argv[])
          {
           System.out.println(mraa.getVersion()); 
              System.out.println("This has been a test of Intel Edison \n"); 
          }     
      }
      

       

      I put that file "HelloEdison.java" in my home directory and I run:

      "javac -cp /usr/lib/java/mraa.jar -d bin HelloEdison.java" (note that if I use "/ur/lib/java/*.jar" it fails because "tinyb.jar is an invalid flag")

      and it compiles with no issue. "HelloEdison.class" appears in the bin directory.

      I move to the bin directory and run:

      "java -cp /usr/lib/java*:HelloEdison.java HelloEdison"

      and I get the following error:

       

      Exception in thread "main" java.lang.NoClassDefFoundError: mraa/mraa

           at HelloEdison.main(HelloEdison.java:26)

      Cause by: java.lang.ClassNotFoundException: mraa.mraa

      etc etc

       

      What am I doing wrong?