Eclipse and JDK 1.6.0_05 on Mac OS

Last week, Java 1.6 went out of Developer Preview and became an “official” release for Mac OS 10.5.2. (You still can’t get 1.6 for 10.5.1, sadly.) I’ve been fiddling with 1.6 and Eclipse, trying to get them to play well together, and here’s what I’ve found so far.

Eclipse itself needs to run on 1.5. There’s a great blog post, “Running Eclipse on MacBooks with Java 6”, written by one “rkischuk,” that explains why: 1.6 doesn’t support 32-bit SWT-Cocoa bindings, so Eclipse will bomb. The error I got was a mysterious “JVM Terminated. Exit code=-1” and a list of run-time options. If you run Eclipse from a shell, you might see this:

2008-05-09 10:53:55.443 eclipse[257:10b] Cannot find executable for CFBundle 0x116030 (not loaded)

or maybe this:

_NSJVMLoadLibrary: NSAddLibrary failed for /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Libraries/libjvm.dylib
JavaVM FATAL: Failed to load the jvm library.

When I installed 1.6, I had messed around with /System/Library/Frameworks/JavaVM.framework/Versions, trying to get 1.6 to run as the system default. But the cleanest solution for me was to KEEP 1.5 as the default. So make sure that directory looks like this:

drwxr-xr-x 11 root wheel 374 May 9 10:49 ..
lrwxr-xr-x 1 root wheel 5 May 5 22:41 1.3 -> 1.3.1
drwxr-xr-x 3 root wheel 102 Nov 2 2007 1.3.1
lrwxr-xr-x 1 root wheel 5 Apr 18 13:07 1.4 -> 1.4.2
lrwxr-xr-x 1 root wheel 3 May 5 22:41 1.4.1 -> 1.4
drwxr-xr-x 8 root wheel 272 Apr 27 2007 1.4.2
lrwxr-xr-x 1 root wheel 5 Apr 18 13:07 1.5 -> 1.5.0
drwxr-xr-x 8 root wheel 272 Apr 27 2007 1.5.0
lrwxr-xr-x 1 root wheel 5 May 5 22:41 1.6 -> 1.6.0
drwxr-xr-x 8 root wheel 272 Apr 18 14:03 1.6.0
drwxr-xr-x 9 root wheel 306 May 9 10:50 A
lrwxr-xr-x 1 root wheel 1 May 9 11:13 Current -> A
lrwxr-xr-x 1 root wheel 3 May 9 11:12 CurrentJDK -> 1.5

Eclipse should run as it normally does.

If your code project(s) don’t require SWT, you can use 1.6 as an Installed JRE within Eclipse. Go to Preferences -> Java -> Installed JREs -> Add…. Select “Mac OS VM” and point it to:

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

Building projects and running JBoss using the 1.6 seems to work just fine.

15 thoughts on “Eclipse and JDK 1.6.0_05 on Mac OS

  1. Boris DuĊĦek

    Thanks so much for posting this! I also messed up with the 2 symlinks, I solved it by making “Current” to point to “A” instead of any specific version (1.5 in my case), according to your listing.

  2. Florian

    If you want version 1.6 as the default
    your directory (/System/Library/Frameworks/JavaVM.framework/Versions/) looks like :

    $ ls /System/Library/Frameworks/JavaVM.framework/Versions/
    drwxr-xr-x 11 root wheel 374 May 9 10:49 ..
    lrwxr-xr-x 1 root wheel 5 May 5 22:41 1.3 -> 1.3.1
    drwxr-xr-x 3 root wheel 102 Nov 2 2007 1.3.1
    lrwxr-xr-x 1 root wheel 5 Apr 18 13:07 1.4 -> 1.4.2
    lrwxr-xr-x 1 root wheel 3 May 5 22:41 1.4.1 -> 1.4
    drwxr-xr-x 8 root wheel 272 Apr 27 2007 1.4.2
    lrwxr-xr-x 1 root wheel 5 Apr 18 13:07 1.5 -> 1.5.0
    drwxr-xr-x 8 root wheel 272 Apr 27 2007 1.5.0
    lrwxr-xr-x 1 root wheel 5 May 5 22:41 1.6 -> 1.6.0
    drwxr-xr-x 8 root wheel 272 Apr 18 14:03 1.6.0
    drwxr-xr-x 9 root wheel 306 May 9 10:50 A
    lrwxr-xr-x 1 root wheel 1 May 9 11:13 Current -> A
    lrwxr-xr-x 1 root wheel 3 May 9 11:12 CurrentJDK -> 1.6

    (CurrentJDK linked to 1.6)

    To run eclipse proprely :
    1. Go to your Eclipse folder
    containing theses files : Eclipse.app/ configuration/ eclipse@ features/ p2/ readme/ artifacts.xml dropins/ epl-v10.html notice.html plugins/
    2. Edit the file named Info.plist in Eclipse.app/Contents/Info.plist
    3. Uncomment this line(30) -vm/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java
    4. Launch Eclipse in your Finder, it’s works !

    Enjoy it

  3. Florian

    The line is <
    string>
    -vm<
    /string><
    string>/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java<
    /string>

  4. SleepbotZZ

    awesome! but a hard one to track down.

    for instance, if you turn on -debug, or read the ‘JVM terminated’ dialog, the ‘-vm’ option always says

    -vm /System/Library/Frameworks/JavaVM.framework

    regardless of whether you use -vm from the command line, Info.plist *or* eclipse.ini . that’s a pretty serious red herring which kept me fighting this for hours. especially when other blogs claim that there’s no solution due to Carbon vs. 64 bit issues:

    http://stackoverflow.com/questions/245803/jvm-terminates-when-launching-eclipse-mat-on-mac-os-with-j2se-60

    the solution above works great. thanks

  5. Ashish

    It does not seem to work for me. :(

    This is what i have

    lrwxr-xr-x 1 root wheel 5 Jan 15 12:24 1.3 -> 1.3.1
    drwxr-xr-x 3 root wheel 102 Sep 29 2007 1.3.1
    lrwxr-xr-x 1 root wheel 5 Jan 15 12:24 1.4 -> 1.4.2
    lrwxr-xr-x 1 root wheel 3 May 17 2008 1.4.1 -> 1.4
    drwxr-xr-x 8 root wheel 272 Mar 7 2008 1.4.2
    lrwxr-xr-x 1 root wheel 5 Jan 15 12:24 1.5 -> 1.5.0
    drwxr-xr-x 9 root wheel 306 Feb 2 16:33 1.5.0
    lrwxr-xr-x 1 root wheel 5 Jan 15 12:24 1.6 -> 1.6.0
    drwxr-xr-x 9 root wheel 306 Feb 4 11:57 1.6.0
    drwxr-xr-x 9 root wheel 306 Feb 2 16:34 A
    lrwxr-xr-x 1 root wheel 3 Feb 4 12:01 Current -> 1.5
    lrwxr-xr-x 1 root wheel 5 May 10 14:03 CurrentJDK -> 1.5.0

    and I have also uncommented the -vm option in info.plist to point to /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java

    Now when i double click on eclipse.app, i see the -vm as /System/Library/Frameworks/JavaVM.framework only and it terminates with JVM Terminated -1.
    I am pasting the full trace here….any help

    Exit code=-1
    -Xms40m
    -Xmx512m
    -Xdock:icon=../Resources/Eclipse.icns
    -XstartOnFirstThread
    -Dorg.eclipse.swt.internal.carbon.smallFonts
    -XX:MaxPermSize=256m
    -Djava.class.path=/Users/achawla/temp/eclipse/Eclipse.app/Contents/MacOS/../../../plugins/org.eclipse.equinox.launcher_1.0.200.v20090429-1630.jar
    -os macosx
    -ws cocoa
    -arch x86_64
    -showsplash
    -launcher /Users/achawla/temp/eclipse/Eclipse.app/Contents/MacOS/eclipse
    -name Eclipse
    –launcher.library /Users/achawla/temp/eclipse/Eclipse.app/Contents/MacOS/../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.0.0.v20090429-1630/eclipse_1205.so
    -startup /Users/achawla/temp/eclipse/Eclipse.app/Contents/MacOS/../../../plugins/org.eclipse.equinox.launcher_1.0.200.v20090429-1630.jar
    -keyring /Users/achawla/.eclipse_keyring
    -showlocation
    -vm /System/Library/Frameworks/JavaVM.framework
    -vmargs
    -Xms40m
    -Xmx512m
    -Xdock:icon=../Resources/Eclipse.icns
    -XstartOnFirstThread
    -Dorg.eclipse.swt.internal.carbon.smallFonts
    -XX:MaxPermSize=256m
    -Djava.class.path=/Users/achawla/temp/eclipse/Eclipse.app/Contents/MacOS/../../../plugins/org.eclipse.equinox.launcher_1.0.200.v20090429-1630.jar

  6. David

    Thanks very much for posting this. I too downloaded Java 1.6.0 from Apple and found Eclipse bombed. I struggled for about an hour until I found your posting. Thank you.

    I ahd to convert back to Java1.5 as default. To do this I changed the /System/Library/Frameworks/JavaVM.framework/Versions to look just as described in the original posting. I had Current pointing to 1.5.0 then 1.5, but it needs to point to A, and CurrentJDK to 1.5. So an ls -l gives:
    lrwxr-xr-x 1 root wheel 5 Oct 9 2008 1.3 -> 1.3.1
    drwxr-xr-x 3 root wheel 102 Jan 14 2008 1.3.1
    lrwxr-xr-x 1 root wheel 5 Oct 9 2008 1.4 -> 1.4.2
    lrwxr-xr-x 1 root wheel 3 Jun 15 2008 1.4.1 -> 1.4
    drwxr-xr-x 8 root wheel 272 Jun 14 2008 1.4.2
    lrwxr-xr-x 1 root wheel 5 Oct 9 2008 1.5 -> 1.5.0
    drwxr-xr-x 8 root wheel 272 Jun 14 2008 1.5.0
    lrwxr-xr-x 1 root wheel 5 Oct 9 2008 1.6 -> 1.6.0
    drwxr-xr-x 8 root wheel 272 Jun 15 2008 1.6.0
    drwxr-xr-x 8 root wheel 272 Oct 9 2008 A
    lrwxr-xr-x 1 root wheel 1 May 17 23:22 Current -> A
    lrwxr-xr-x 1 root wheel 3 May 17 23:23 CurrentJDK -> 1.5

  7. Gino

    I actually want to start the new Eclipse with Java 1.6. If I don’t I, the JUnit plugin is not able to run my JDK1.6 test cases… But it doesn’t seem to work, both Carbon and Cocoa distributions give problems…

  8. Ian

    Just wanted to say thanks. I had screwed up my Snow Leopard Java while trying to get my MagicDraw to work. Even the Java Prefs applet didn’t work. I have a Mac Air, and reinstalling the OS would have been a nightmare.

    Just saying THANKS – you’re tip showed that I had a FUBAR Versions directory, and by changing the CurrentJDK link, I’m back in business. Shame about my MagicDraw though. Hopefully someone will figure a workaround.

    Apple are trying to sabotage Java ?!

  9. Michael Minella

    Just wanted to say thanks for the post. I foolishly did a java upgrade on my Leopard laptop which messed up my JVMs. This saved me hours of reinstalling Eclipse and FlexBuilder. Thanks again!

Leave a Reply

Your email address will not be published. Required fields are marked *