Archive

Archive for the ‘Java Mac’ Category

Unsupported major.minor version 49.0 with SunSPOT manager

25 May 2008 2 comments

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

How to run the SunSPOT manager

14 May 2008 8 comments

When you install the SunSPOT software you will notice that there is a SPOTManager.jnlp (web start) file. You can use this file to run the SunSPOT manager but it will most likely fail (it failed with me). There are three ways you can run it.

The easiest is to just run it from SunSPOT’s web site.

The second is to get all the needed jar files in your file system and change the  SPOTManager.jnlp file by hand to point to the location of these files. The jar files you need are

  • SPOTManager.jar
  • swing-layout-1.0.3.jar
  • activation.jar
  • mail.jar
  • PDFRenderer.jar

You can get these files from their corresponding web sites, or for convenience download them from http://www.sunspotworld.com/SPOTManager/dist/. You will need to append the file name of each jar at the end of the url: http://www.sunspotworld.com/SPOTManager/dist/SPOTManager.jar and so on.

Once you have downloaded all of them change the  SPOTManager.jnlp file to look something like that

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="file:///Users/panos/Java/SunSPOT/" href="SPOTManager.jnlp">
    <information>
        <title>SPOTManager</title>
        <vendor>Sun Labs</vendor>
        <description>SPOTManager</description>
        <description kind="short">SPOTManager</description>
        <homepage href="http://www.sunspotworld.com/"/>
        <icon href="SpotDownload.png" kind="default"/>
        <icon href="SpotSplash.png" kind="splash"/>
    </information>
    <resources>
        <j2se version="1.5+"/>
        <jar href="webstart/SPOTManager.jar" main="true" download="eager"/>
        <jar href="webstart/swing-layout-1.0.3.jar" download="eager"/>
        <jar href="webstart/activation.jar" download="eager"/>
        <jar href="webstart/mail.jar" download="eager"/>
        <jar href="webstart/PDFRenderer.jar" download="eager"/>
    </resources>
<security>
    <all-permissions/>
  </security>
    <application-desc main-class="sunspot.spotmanager.Main">
    </application-desc>
</jnlp>


Note that I have changed the codebase to point to a file on the local file system instead of the web. And also the jar file is referenced relevant to where the  SPOTManager.jnlp file is. If SPOTManager.jnlp is in folder x then the mail.jar should be in x/webstart/mail.jar.

Also, it’s very important to sign the jars from the beginning again. And sign them all with the same signature. You can create your own certificate to do that.

If you have followed all the steps correctly you should be able to run the SunSPOT manager.

The third solution is similar to the first one. Instead of having the files served directly from the file system you can upload them to the local apache server (to start the apache  System Preferences – Sharing – Personal Web Sharing. This should start the apache) and have apache serve them for you. Then doubl click again the SPOTManager.jnlp and the manager should start.

Categories: Java, Java Mac, SunSPOT

How to install SunSPOT on a Mac

13 May 2008 1 comment

In JavaOne this year I was lucky enough to get my hands on a SunSPOT (thank you Sun). SunSPOTs are small programmable devices that have a JVM installed and can be programmed in Java. Installing SunSPOTs on Mac (I am running Tiger) it’s pretty straight-forward. The step by step instructions are

  • Install the XCode tools if they are not installed already. This is a very basic step since if you don’t install them the SunSPOT installer will most probably hang with a “Relocating updated Ant” message.
  • Run the SunSPOTSDKInstaller.jar file from the CD that comes with the SunSPOT box.
  • If you get the following error message “UUCP Group Membership for <username>: Failed!” you can try the following commands:
    • sudo mkdir /var/spool/uucp
    • sudo chmod 775 /var/spool/uucp/
      (these two commands seemed to do the trick for me)
  • Then re-run the SunSPOTSDKInstaller.jar file.

That’s it, the SunSPOT software should install now.

Categories: Java, Java Mac, SunSPOT

13949712720901ForOSX

8 November 2007 Leave a comment
Categories: Java Mac