Thursday, June 26, 2008

Eclipse 3.x and Java 1.6 on OSX

Eclipse 3.x can't run using Java 1.6 on OSX. It is a known issue and probably won't be resolved for a while thanks to the fact that Apple has only shipped a 64bit 1.6 JVM. Thus, in order to get Eclipse 3.x to run with Java 1.6 set as command line default on OSX, you need to do the following:
  1. In /System/Library/Frameworks/JavaVM.framework/Versions, symlink CurrentJDK -> 1.6. Leave Current -> A
  2. I also changed the location of the java binary to: /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/java
  3. Right/Ctrl click on the Eclipse icon, Show Package Contents, edit the Info.plist file and uncomment the line that says: <string>-vm</string><string>/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java</string>
Now, you will have the best of both worlds as things stand today. Java 1.6 on the command line and Eclipse running under 1.5. Oh, by the way, if you haven't noticed yet, Eclipse 3.4 is out.

8 comments:

Adrian said...

Don't change the symlinks around - it will come back to bite you. You can use the Java Preferences control panel to change the Java version for most situations, including the command line java and javac commands. For everything else just treat it like a standard UNIX system and adjust your PATH and JAVA_HOME variables.

Adjusting the symlinks has never been required on OS X and has always been strongly discouraged by Apple.

Jon Scott Stevens said...

Yea, that didn't work for me.

cygri said...

Worked for me. Yes, messing around with the symlinks will probably bite us in the behind later, but at least it works NOW. Thanks Jon!

Lux said...

Excellent. This really helped me out, too. Thanks for the info.

Neil said...

adrian: Changing the Java version in the control panel doesn't change the CurrentJDK symlink (it does change the Current symlink, it seems).

Jon, thanks for posting this!

Chris Maddern said...

Thanks a lot; working and broke it by fixing something, and now I can work again! :D

Jon Scott Stevens said...

It is funny, I keep coming back to this page myself every couple of months. =)

MrWoodleigh said...

Thanks for the recipe. I just upgraded to Leopard and Java 6 and found myself without a working Eclipse. It's working now!