Install Oracle JDK

Go to the link :

Accept the license agreement and Download the tar.gz file (eg: jdk -8u65-linux-i586.tar.gz)

Extract the file using the command tar -xzvf jdk-8u65-linux-i586.tar.gz

Copy the extracted directory (In my case jdk1.8.0_65) to the required location say /scratch

alternatives –install /usr/bin/java java /scratch/jdk1.8.0_65/bin/java 20000

alternatives –config java

You can see the list of available java versions and select our installed one by typing the number corresponding to that one.