Home > Java, Java Mac, SunSPOT > Unsupported major.minor version 49.0 with SunSPOT manager

Unsupported major.minor version 49.0 with SunSPOT manager

While trying to run the Solarium from the SunSPOT manager I got the following exception


-do-run-spotworld: 
     [echo] Java Runtime Environment version: 1.4.2_16 
     [java] Exception in thread "main" java.lang.UnsupportedClassVersionError: com/sun/spot/spotworld/gui/SpotWorldPortal (Unsupported major.minor version 49.0) 
     [java]    at java.lang.ClassLoader.defineClass0(Native Method) 
...

I algo got a similar exception when I tried to use the base station to deploy a demo to one of the free range SunSPOTs


[java] Exception in thread "main" java.lang.UnsupportedClassVersionError: com/sun/squawk/Romizer (Unsupported major.minor version 49.0) 
[java]     at java.lang.ClassLoader.defineClass0(Native Method) 
[java]     at java.lang.ClassLoader.defineClass(ClassLoader.java:539) 
...

The cause of this error is a class and virtual machine mismatch. It means that a class that was compiled with Java 1.5 is trying to run on a 1.4 environment. In other words I was using Java version 1.4 to run a 1.5 version class. 

Originally I thought there was a problem with the SunSPOTs since they are 1.4 compatible only (as are all Java ME implementations). But after looking at NetBeans and saw that the target platform is 1.4 and after asking a question in the SunSPOT forums I realised that the problem lies with ant. For some reason ant was using the version 1.4.2 that was installed on my computer instead of the 1.5 (the SunSPOT manager needs 1.5 in order to run). I looked at the ant script to see where it’s getting the settings from but to no avail. I even did a grep in order to find out where this setting occurs but still no luck.

I defined ANT_HOME and JAVA_HOME explicitly on the command line and this got the base station to deploy the demo successfully. But the problem with the SunSPOT manager remained.

Finally I decided to expliticly define the JAVA_HOME and JAVACMD settings with my ant script and work around the problem. This solved the issue but I am still curious as to where ant was picking up the wrong version from.

# Extract launch and ant arguments, (see details below).
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/
export JAVACMD=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java

ant_exec_args=
no_config=false

 

Advertisements
Categories: Java, Java Mac, SunSPOT
  1. 15 March 2009 at 3:21 pm

    Thanks for this… it seems to make “ant -diagnostics” to show the right java version for me. However it still tells me

    The J2SE Platform is not correctly set up.
    Your active platform is: JDK_1.6, but the corresponding property “platforms.JDK_1.6.home” is not found in the project’s properties files.

    on doing ant jar. I have no idea why, being a complete newbie at ant…

  2. 15 March 2009 at 5:11 pm

    Hello Kevin, if you are trying to build your project through NetBeans I think you need to set up the Java Platform (from Menu -> Tools-> Java Platform). And then right click on your project and through the preferences set the preferred platform. This should make the error go away.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: