To set JAVA_HOME environment variable, do the following:
Launch Terminal by pressing Ctrl+Alt+T on your keyboard.
Enter the following command: $ gksudo gedit /etc/environment
Depending on where you installed your Java, you will need to provide the full path. For this example, I installed Oracle JDK 7 in the /usr/lib/jvm/java-X-oracle directory. Scroll to the end of the file and enter the following: JAVA_HOME=/usr/lib/jvm/java-X-oracle export JAVA_HOME
Save your file and exit gedit.
Lastly, reload the system PATH with the following command: $ . /etc/environment