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:
JAVA_HOME=/Library/Java/Home
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.

Advertisements

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 Terminal.app (Applications >> Utilities >> Terminal)

    2. type: emacs .profile

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

    JAVA_HOME=/Library/Java/Home
    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:
    MANPATH=/usr/share/man:/usr/local/share/man:/usr/X11/man
    TERM_PROGRAM=Apple_Terminal
    TERM=xterm-color
    SHELL=/bin/bash
    TMPDIR=/var/folders/v9/v9F-5i-mGyqUKWHxyRLiMk+++TI/-Tmp-/
    Apple_PubSub_Socket_Render=/tmp/launch-wwV61I/Render
    TERM_PROGRAM_VERSION=240.2
    USER=Samantha
    COMMAND_MODE=unix2003
    SSH_AUTH_SOCK=/tmp/launch-oCus7e/Listeners
    __CF_USER_TEXT_ENCODING=0x1F5:0:0
    PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
    PWD=/Users/Samantha
    LANG=en_US.UTF-8
    SHLVL=1
    HOME=/Users/Samantha
    LOGNAME=Samantha
    DISPLAY=/tmp/launch-hwKeaW/:0
    SECURITYSESSIONID=833f10
    _=/usr/bin/env
    ——–

    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

    JAVA_HOME=/Library/Java/Home
    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?

    Thanks!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s