There is a difference between installation Java 8 on Ubuntu 14.04 and 16.04. On the 16.04 you can simply execute apt-get with Java 8 installer, whereas on 14.04 you’ll need to add PPA for Java 8. Here’s how to do this on 14.04:
Step #1: Add the WebUpd8 Personal Package Archive (PPA)
sudo apt-add-repository ppa:webupd8team/java
Step #2: Update
Let’s use the best practice and execute
sudo apt-get update
Step #3: The installation
sudo apt-get install oracle-java8-installer
Let’s check our installation by running the following:
javac -version
The output should be the following:
javac 1.8.0_121
It may very depend on the latest java version, but it should definitely start with javac 1.8.****.
The last step is to set up Java Home environment variable by executing:
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
Let’s make sure that our variable is set correctly:
printenv JAVA_HOME
The output should be the same as a value of JAVA_HOME, i.e.:
/usr/lib/jvm/java-8-oracle