Setup JAVA_HOME and path to JDK on Linux (Ubuntu in this example), edit the file .bashrc
$ nano .bashrc
Add the line:
export JAVA_HOME=<path to jdk>
Where <path to jdk> is the path to the installed JDK.
Save it and exit.
To reload .bashrc without log-out and log-in, enter the command:
$ source ~/.bashrc