PDA

View Full Version : Setting JAVA_HOME in Ubuntu Linux


scottcarson
07-15-2009, 04:14 PM
Problem:
I have had a very hard time finding a solution to this so I thought I'd post when I found it. I have installed Java's JSK (running as java-6-sun) on my Ubuntu Linux box but whenever I type:

echo $JAVA_HOME
... the result is a blank line.

Solution:

Edit /etc/jvm, add this line to the top of the list:

/usr/lib/jvm/java-6-sun

Thanks to the above step, the java executable will find the right version of java.

You can confirm this with

java -version

However, setting JAVA_HOME is a completely different matter.

These commands will detect, set, and verify JAVA_HOME:

. /usr/share/java-common/java-common.sh
eval $(jvm_config)
export JAVA_HOME
echo $JAVA_HOME


(Reference: http://my-hacking-journal.blogspot.com/2008/03/installing-java-and-setting-javahome-in.html )