Run Java 6 on mac

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

  1. sknight126 macrumors newbie

    Oct 16, 2007
    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(
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at java.lang.ClassLoader.loadClassInternal(

    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?
  2. garethlewis2 macrumors 6502

    Dec 6, 2006
    You should have it installed in the following place


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

    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

    Oct 16, 2007
    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

    Dec 6, 2006
    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

    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


    Jan 4, 2002
    Austin, TX
    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


    Jun 13, 2007
    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


    Dec 20, 2002
    sunny los angeles
    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

    Oct 16, 2007

    Yes I reset the terminal.

    My /usr/bin/java is referrence to:


    Does this need to be changed to CurrentJDK?

    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