Tinyos Exception on thread "main" java.lang.UnsupportedClassVersionError: Invalid version number in .class file

When I use make command like make mica2 on TinyOS. The following problem arises:

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
make: *** [exe0] Error 1

      

I reinstalled JAVA and added env variables, but that didn't work. I am using TinyOS 2.1 and JAVA 1.5 u18. Can anyone help me?

The problem was solved by installing JDK 1.6. Although when I run the tos-check-env command it shows me a warning that tells me it is not JDK 1.4 or 1.5. This may be a bug in TinyOS.

+1


a source to share


5 answers


UnsupportedClassVersionError means that you are trying to run bytecode on an earlier version of the JVM than it was compiled. You can use the class file viewer to check which version of the JDK was compiled from source and make sure it is compatible with JAVA 1.5 u18.



+4


a source


The error you are getting means that the Java version you are running is trying to load a class that was compiled with an incompatible Java version.

With the information you provide, it is impossible to more accurately diagnose the problem than it is to look at any Java libraries you are using and what their required Java versions are. If you can't find something wrong here, you just need to clear some cached * .class files that were created with the Java version before reinstalling.



Finally, if you have multiple JVMs installed, make sure to make

use the one you expect. Definitely there might be a Java 1.5u18 installation for you, but the application still needs to find and use a 1.4 JVM from somewhere.

+2


a source


I got the same error today and I just solved it by installing java version 1.6 and jre6 and making Java 1.6 version the default.

I also had java 1.5 installed earlier as tos-check-env wanted me to have java 1.4 or java 1.5 versions installed.

I also included the java 1.5 and 1.6 versions in my classpath and ran again make micaz

in the directory /opt/tinyos-2.1.0/apps/Blink

and it worked.

+1


a source


Usually a message like

(Unsupported major.minor version 49.0)

      

in the first line of the exception message. However, you got

Bad version number in .class file

      

So, maybe your class file is corrupted?

0


a source


Use sudo update-alternatives --config java and install the version you can use.

0


a source