Installing Java 1.6 JDK on OS X Leopard with Maven in mind…
By default OS X Leopard (10.5.5) ships with Java JDK 1.5 as the default JDK. This is fine until you actually need to compile an app dependent on 1.6, or even run an app that demands the latest API for JRuby or even Glassfish.
If you search the web for “OS X Java JDK 1.6″ you’re likely to get blog posts related to the “SoyLatte” release of JDK 1.6. These blogs generally provide shell commands and environment setups that are required to compile the “SoyLatte” build of Java 1.6 for OS X. Aside from the lengthy process description, the real frustration comes in the contradictory experiences posted in the comments of said blogs. Quickly, the “upgrade” becomes disheartening.
There’s hope! (And it’s surprisingly easy…)
From Finder simply open “/Applications/Utilities/Java/Java Preferences” and drag “1.6″ to the top of the list. You should now be able to confirm JDK 1.6 from the Terminal by typing “java -version”. You should see “1.6″ (or something at least starting in 1.6.)
Now for Maven. The tricky part lies in your environmental $JAVA_HOME variable being set to the JDK 1.5 path. In the terminal, locate your Bash profile. (Mine lives at “/etc/profile”.) You’ll need to run “sudo” to edit and save the file.
Inside profile, you should have the following line as required by Maven:
JAVA_HOME=/Library/Java/Home; export JAVA_HOME;
If you do not see this line – I’m not sure this post applies to you…
Anyhow, “/Library/Java/Home” is a symbolic link that is still pointing to the JDK 1.5 “bin”, which prevents Maven from running the appropriate Java version. (This, of course, is correct if you’re forcing JDK versions through Maven.)
You’ll now want to alter the $JAVA_HOME variable to the following:
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home; export JAVA_HOME;
Save your profile, open a new Terminal session — that should do it. Via the OS X preferences pane, you’ve directed OS X to the JDK 1.6. While through the $JAVA_HOME variable, you’ve pointed Maven to the appropriate JDK.
Hope that helps.
douger963 said,
November 27, 2008 at 11:31 pm
From Finder simply open “/Applications/Utilities/Java/Java Preferences” and drag “1.6″ to the top of the list. You should now be able to confirm JDK 1.6 from the Terminal by typing “java -version”. You should see “1.6″ (or something at least starting in 1.6.)
I have OS 10.5.5 and I don’t have a 1.6 to drag to the top of the list. I just updated my system software. And I’ve done the SoyLatte installs for 1.6 and run:
java -version
Still get 1.5
I guess I need more of a clue
cs44 said,
November 28, 2008 at 3:54 am
Sry – it’s actually “Java SE 6″. Is that option available?
Also, when you type “set” at the terminal prompt – what is your $JAVA_HOME ??
EJ said,
December 17, 2008 at 3:59 am
Thank you!
h MacKiernan said,
December 21, 2008 at 11:56 pm
OMG advice on setting up a development environment on Leopard that _actually works_ — without the typical magical thinking of “I changed my desktop background and that still didn’t help” that I usually encounter. Thank you _very_ much!
cs44 said,
December 22, 2008 at 6:30 pm
No problem, glad you found it helpful =)
themrx said,
February 24, 2009 at 3:52 am
Hey, thanks for this! I was pulling my hair out trying to get 1.6 working on Leopard. You saved the last patch!
Zack said,
March 5, 2009 at 11:03 am
Good call cs44. Fit my situation exactly.
Taysay said,
May 27, 2009 at 1:09 pm
Hi this is simply amazing I have being wondering how to do this.
my question is I see Java SE 6 and 64 bit so I am wondering if my system is a 64 bit, b’cos I have java 5 32 bit running at the moment, secondly I want to know if I have to do the soyLatte ? Thanks a bunch
cs44 said,
May 27, 2009 at 5:19 pm
You should not have to do soyLatte. Also, if you’re on an intel mac – you are 64-bit. Hope that helps!
Brett said,
May 27, 2009 at 8:12 pm
Awesome post, just what i was looking for. Thanks!
links for 2009-08-08 at adam hoyle presents suckmypixel said,
August 8, 2009 at 12:31 pm
[...] Installing Java 1.6 JDK on OS X Leopard with Maven in mind… « cs44’s so fresh software blog, (tags: javascript OSX programming mac help maven) [...]
Ngoc said,
August 23, 2009 at 6:05 pm
If java -version gives 1.5, see:
http://www.deliciouscoding.com/post.cfm?entry=change-default-leopard-java-jdk-1-5-to-1-6-the-easy-way
chris said,
September 3, 2009 at 6:09 pm
looking for this solution quite a long time. Thanks.