Search code examples
javatinyos

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


When I use make command, like make mica2, in TinyOS. The following problem will occured:

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 add env variables, but it didn't work. I use TinyOS 2.1 and JAVA 1.5 u18. Can any one help me?

Problem solved by install JDK 1.6. Although when I run tos-check-env command, it shows me a warning that tell me its not JDK 1.4 or 1.5. Maybe it is a bug in TinyOS.


Solution

  • an UnsupportedClassVersionError means you are trying to run byte code on an older version of the JVM than it was compiled in. You can use a class file viewer to check which version of the JDK the source code was compiled it and make sure it is compatible with JAVA 1.5 u18.