I found this post and found it better than modifying /etc/profile
This works for both Ubuntu and CentOS from what I can see.
Find the location of your jvm. ex: /usr/lib/jvm/java-6-sun/
Add a line to your environment file:
sudo pico /etc/environment
Then just add the following to the end (or whatever the location of your jvm was):
JAVA_HOME=/usr/lib/jvm/java-6-sun/
Log out, and log back in.
Open a terminal and run “echo $JAVA_HOME”, which should give you /usr/lib/jvm/java-6-sun
Find the location of your jvm. ex: /usr/lib/jvm/java-6-sun/Add a line to your environment file:
sudo pico /etc/environmentThen just add the following to the end (or whatever the location of your jvm was):
JAVA_HOME=/usr/lib/jvm/java-6-sun/Log out, and log back in.
Open a terminal and run “echo $JAVA_HOME”, which should give you /usr/lib/jvm/java-6-sun