How to set JAVA_HOME to point to a JDK installation?

You should be able to use the whereis command to find where your JDK is installed.

whereis java

On my Ubuntu 12.04 install, OpenJDK has files located in /usr/bin/java, /usr/bin/X11/java, /usr/share/java, /usr/share/man/man1/java.1.gz. I'm guessing the Oracle version is located in the same directories.


If you need to add JAVA_HOME variable, you can do so by adding it to the .bashrc file in your home directory

Open .bashrc file using an editor. If you use nano then

nano ~/.bashrc

and add the following 2 lines in your .bashrc file.

JAVA_HOME=/usr/lib/jvm/jdk1.7.0_04/
export JAVA_HOME

There may be other ways to install, but this is what I have followed always.