This post is more for my memory than anything. I always forget and need to dig around to figure out how (or more importantly “where”) to set JAVA_HOME in Ubuntu. It’s pretty simple.
- 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/
Related posts:




4 Responses
rgm
22|Oct|2010If you happen to switch JVMs a lot, then this is a bit more flexible / automatic:
export JAVA_HOME=$( dirname $( dirname $( readlink -e /usr/bin/java ) ) )
Jeff Barron
25|Nov|2011Thanks RGM! Also Trent I found you by accident via mix up with heisman candidate alabama running back Trent Richardson ;)
still like the blog.
Do you use the latest Ubuntu or are you still using 10.?
trent
25|Nov|2011Hey Jeff, I’m running Ubuntu 11, but holding out on Unity..
james
06|Jan|2012Dont do this… this will create problems for yo…