JAVA_HOME on Mac OS X 10.5

I normally don’t mess with Java so this is likely a trivial point, I could very well be stating the most obvious of obvious things.

The documentation for Amazon’s EC2 Web Service actually had a well written explanation, but who reads? Scanning the setup instructions I saw:

  • Java. — Check, I got that
  • Java JRE version 1.5 — Check? [smbrown@jrcash$] java -version
  • JAVA_HOME — Check? [smbrown@jrcash$] which java
  • FAIL

JAVA_HOME is /Library/Java/Home it is the location where the sub folders bin/java/

What is my “JAVA_HOME“? it is “the full path of the directory that contains a sub-directory named bin which in turn contains the java

To see your current JAVA_HOME:
[smbrown@jrcash$] echo $JAVA_HOME

To set a JAVA_HOME, insert this in your ~/.profile:
export JAVA_HOME;

What is a better way to confirm your real Java version JAVA_HOME on OS X?

[smbrown@jrcash$] $JAVA_HOME/bin/java -version

Thanks for taking a look you can go back to Twittering now. =)

Update (January 10, 2009): Amazon released their AWS Web Console, here’s an early tour.

18 thoughts on “JAVA_HOME on Mac OS X 10.5

  1. Pingback: Setting JAVA_HOME on Mac OS X 10.5 — Entrepreneur Geek

  2. @michael

    1. Open up (Applications >> Utilities >> Terminal)

    2. type: emacs .profile

    3. add this to the end of the .profile file:

    export JAVA_HOME;

    4. Save and exit emacs (ctrl-x, ctrl-s; ctrl-x, ctrl-c)

    5. open a new Terminal window (cmd-n) and type: $JAVA_HOME/bin/java -version

    If you see something like:
    java version “1.5.0_16”
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
    Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)

    Then you’ve successfully set your JAVA_HOME environment variable to the binary stored in /Library/Java/Home/bin/java

  3. I am unable to locate .profile. When I do sudo pico ~/.profile or emacs ~/.profile, I get a new empty file.
    And then when I type in ‘env’ i get a full listing of properties as:

    Now where are these properties coming from? These properties are in some file and I can’t locate them. What should I do?

  4. @ilango gurusamy

    You can add these lines to a new, empty file in ./profile

    export JAVA_HOME;

    save and then open a new terminal window to view the changes. The other settings set at login by the system-wide bash settings (vs. the user-specific environment settings which are kept in ./profile)

  5. Thank you. I would like to add a link to your blog in my blog where I am writing up my own account of how to set up Java 6 for Mac OS Leopard. Can I do that?
    Is there any other way I can acknowledge your help in solving my problem?

  6. Thanks for the info.
    I wrote the following in ~/.profile:
    export JAVA_HOME=/Library/Java/Home

    but it turns out that when I type echo $JAVA_HOME
    it only returns a blank line.
    Why is that?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s