Installing Java 1.6 JDK on OS X Leopard with Maven in mind…

November 18, 2008 at 7:14 pm (Uncategorized) (, , , , , )

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.

13 Comments

  1. douger963 said,

    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

  2. cs44 said,

    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 ??

  3. EJ said,

    Thank you!

  4. h MacKiernan said,

    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!

  5. cs44 said,

    No problem, glad you found it helpful =)

  6. themrx said,

    Hey, thanks for this! I was pulling my hair out trying to get 1.6 working on Leopard. You saved the last patch!

  7. Zack said,

    Good call cs44. Fit my situation exactly.

  8. Taysay said,

    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,

      You should not have to do soyLatte. Also, if you’re on an intel mac – you are 64-bit. Hope that helps!

  9. Brett said,

    Awesome post, just what i was looking for. Thanks!

  10. links for 2009-08-08 at adam hoyle presents suckmypixel said,

    [...] 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) [...]

  11. Ngoc said,

  12. chris said,

    looking for this solution quite a long time. Thanks.

Post a Comment