Setting JAVA_HOME on Mac OS X

Some time ago I had set JAVA_HOME in my .profile on Mac OS X to the following:

To some extent this works, but it doesn’t apparently pick up your preferred JDK version that you can set via the Java Preferences app in /Applications/Utilities (you set your preferred version by dragging your choice to the top of the list).

To set JAVA_HOME to be set to your preferred version, use this instead:

This post here talks about the first approach, but there’s a comment in response to the post that points out the second point.

This entry was posted in Tech Notes and tagged , , . Bookmark the permalink.

2 Responses to Setting JAVA_HOME on Mac OS X

  1. Steve Coy says:

    You may find it useful to add this to your .bash_profile:

    alias java6="export JAVA_HOME=
    /usr/libexec/java_home -v1.6"
    alias java7="export JAVA_HOME=/usr/libexec/java_home -v1.7"

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">