Eu tentei muitas soluções, mas isso funcionou para mim Solução . Eu estou postando isso para que possa ser útil para os outros
Create an empty folder so that we can install java 1.8
sudo mkdir /opt/java && cd /opt/java
Now lets download java-1.8 version
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz"
Extract the tar file
tar -zxvf jdk-8u45-linux-x64.tar.gz
Now lets update the alternatives so that system will point to the location where java-1.8 is installed
cd jdk1.8.0_45/
sudo update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.0_45/bin/java 100
Note: The 100 in above command represents the priority no. which can set manually
sudo update-alternatives --config java
Please enter the selection no. which is having the path as “/opt/java/jdk1.8.0_45/bin/java” and press enter.
sudo update-alternatives –install /usr/bin/javac javac /opt/java/jdk1.8.0_45/bin/javac 100
sudo update-alternatives –config javac
sudo update-alternatives –install /usr/bin/jar jar /opt/java/jdk1.8.0_45/bin/jar 100
sudo update-alternatives –config jar
Now lets try to set up the environment variables