Steps to install Oracle java on Ubuntu 14.04
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
#install java 8
sudo apt-get install oracle-java8-installer
#show installed version of java
update-alternatives --config java
nano /etc/environment
JAVA_HOME="YOUR_PATH"
source /etc/environment
echo $JAVA_HOME
change default version of java in your system
update-alternatives --config java
or by the next bash script
#/usr/bin/sh
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
#install java 8
sudo apt-get install oracle-java8-installer
#show installed version of java
echo 'JAVA_HOME="/usr/lib/jvm/java-8-oracle"' >> /etc/environment
source /etc/environment
echo $JAVA_HOME
echo "!!!ALL DONE!!!"