Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.


For the millionth time, cause I always forget…

Put this in ~/.bashrc:

export JAVA_HOME=/Library/Java/Home

[UPDATE: or this, which according to Mike Swingler, follows the Java version chosen in Java Preferences:

export JAVA_HOME=`/usr/libexec/java_home`


Also, run “sudo visudo” and add the line

Defaults        env_keep += "JAVA_HOME"

or else commands like “sudo gem install” won’t be able to find Java.

Without the above, I got the following error (which seemed to have been run through a baby-talk filter) when running “sudo gem install rjb”:

extconf.rb:44: JAVA_HOME is not setted. (RuntimeError)

  1. You just saved me a couple of hours, thanks for putting this up.

  2. sfdc says:

    wow. that was incredibly useful! thanks so much for the great post.

  3. Thanks! This helped tons!

  4. Mike Swingler says:

    You should use the /usr/libexec/java_home command, since it always follows the Java version choosen in Java Preferences.

  5. Lennart Jörelid says:

    Hello Alex,

    I usually do these lines within my .bash_profile, to be able to quickly and smoothly switch between java versions on Mac. (This is really nice when wanting to test some code on multiple java versions). When I need to switch JDK, I simply use either of the aliases


    The snippets for this in .bash_profile are:

    # Set roots for JDK version switching
    export JAVA_HOME_ROOT=/System/Library/Frameworks/JavaVM.framework/Versions
    export JAVA_15_HOME=${JAVA_HOME_ROOT}/1.5/Home
    export JAVA_16_HOME=${JAVA_HOME_ROOT}/1.6/Home

    # Add JAVA_HOME to the path

    # Augment the path
    export PROTO_PATH=/Users/lj/Bin:${M2_HOME}/bin:/usr/local/bin:$PATH:/Users/lj/Bin:${GERONIMO_HOME}/bin:/Library/PostgreSQL/8.3/bin
    export PATH=${PROTO_PATH}:${JAVA_HOME}/bin

    # Manage JDK switching
    function useJdk16()
    # Assign JAVA_HOME
    export JAVA_HOME=${JAVA_16_HOME}

    # Adjust the path
    export PATH=${JAVA_HOME}/bin:${PROTO_PATH}
    function useJdk15()
    # Assign JAVA_HOME
    export JAVA_HOME=${JAVA_15_HOME}

    # Adjust the path
    export PATH=${JAVA_HOME}/bin:${PROTO_PATH}

    # Define the standard JDK when working with the terminal.
    useJdk16 ;

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *