Run Java 6 on mac

Discussion in 'Mac Programming' started by sknight126, Oct 16, 2007.

  1. sknight126 macrumors newbie

    Joined:
    Oct 16, 2007
    #1
    I have come accross the error,

    java -jar comirva-0.10d.jar
    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(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

    I believe this is because I didn't have Java 6 on my mac. I have now managed to get a beta version of Java 6 however the same problem occurs. When I identify the version I get this,
    java -version
    java version "1.5.0_07"
    How do I get the jar file to run in Java 6?
    Thanks
     
  2. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #2
    You should have it installed in the following place

    /System/Library/Frameworks/JavaVM.framework/Versions

    In there you will see a series of directories, e.g.

    1.3.1
    1.4.2
    1.5.0
    1.6.0 or 6.0

    Then there will be a symbolic link called CurrentJDK which references currently 1.5.0.

    You need to change that link to 1.6.0 or 6.0 or whatever you have. Then you will have Java 6 running as the default. You must be sure to understand the reason, this is not installed as the default is it is as stable as Windows ME.
     
  3. sknight126 thread starter macrumors newbie

    Joined:
    Oct 16, 2007
    #3
    I deleted the old Current JDK and then used:

    sudo ln -s -f /System/Library/Frameworks/JavaVM.framework/Versions/1.6 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

    and I get:

    ls -l /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

    lrwxr-xr-x 1 root wheel 56 Oct 16 10:47 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK -> /System/Library/Frameworks/JavaVM.framework/Versions/1.6

    However when I type

    java -version I still get:

    java version "1.5.0_07"

    and so the same error message is occuring.
     
  4. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #4
    Two things.

    Did you restart terminal after you made the change?

    If not type the command hash -r to recreate the hash table. Then type java -version again

    If this doesn't work do the following.

    check what /usr/bin/java is referenced to.

    It should be set to the
    /System/Library/JavaVM.framework/Versions/CurrentJDK/Commands/java

    Then you run the command

    ls -ltr /System/Library/JavaVM.framework/Version/CurrentJDK/

    It should respond with 1.6.0 or whatever you have.

    If this doesn't your symbolic link was created incorrectly.
     
  5. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #5
    Where did you get Java 6 for OS X? I don't see it listed in the ADC or on Sun's downloads page for Java.
     
  6. jstad macrumors regular

    jstad

    Joined:
    Jun 13, 2007
    #6
    He is compiling from source. Which is possible just some people feel pointless since now the Java Bridge has been sniped out by Apple for Leopard.
     
  7. janey macrumors 603

    janey

    Joined:
    Dec 20, 2002
    Location:
    sunny los angeles
    #7
    Sounds like free ADC accounts can get you a preview version of Java 6 for OS X. Can't verify cause I have a paid membership, but there's enough mention on Google... :eek:

    That being said, you could also wait for Leopard :)
     
  8. sknight126 thread starter macrumors newbie

    Joined:
    Oct 16, 2007
    #8
    Firstly

    Yes I reset the terminal.

    My /usr/bin/java is referrence to:

    /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

    Does this need to be changed to CurrentJDK?

    Secondly
    There is a beta version for Java 6 but it was pulled from the apple developers website a while back. I managed to download it after lots of googling.
     

Share This Page