tags:

views:

1895

answers:

4

Hi,

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

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version n umber 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?

Thank you

Thank you everyone. 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.

+4  A: 

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.

neesh
A: 

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

With the information you've provided it's not possible to diagnose the problem any more specifically than this - look at any Java libraries you're using and what their required Java versions are. If you can't find anything wrong here, you might just need to clean out some cached *.class files that were built with a version of Java before the reinstall.

Finally, if you have multiple JVMs installed be sure that make is using the one you expect. It's definitely possible for you to have installation Java 1.5u18 but for the application to still be finding and using a 1.4 JVM from somewhere.

Andrzej Doyle
A: 

Normally there would be a message such as

(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?

starblue
A: 

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

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

I also included both the java 1.5 and 1.6 versions to my classpath and ran "make micaz" again in the /opt/tinyos-2.1.0/apps/Blink directory and it worked.

I hope this helps.

Regards,

Akshaya Aradhya

Teaching Assitant, Department of Computer Science, SMU

Akshaya Aradhya