If you need a different version or are targeting a different version of Java, change version number accordingly the rest is the same.
Going in hard; let's get some root on
sudo su Enter password if you need to.
If you prefer, you can enter sudo before each command.
apt-get install openjdk-7-jre-headless
Little tip: Installing
locatehelps a whole lot on Linux, in Ubuntu, it's usually installed by default (if it's not, Ubuntu will tell you to apt-get install locate)
In the case of Java Ubuntu (and Debian based releases) installs Java into
/usr/lib/jvm so navigating to it,
cd /usr/lib/jvm then
ls will give you your folder path. There should be one with a long version than a short one like this...
ls /usr/lib/jvm default-java java-1.7.0-openjdk-amd64 java-7-openjdk-amd64
Set the paths
Make a note of the paths then:
Then add your paths before the if statement.
export PATH=$PATH:/usr/lib/jvm/java-7-openjdk-amd64/bin export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64