wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.tar.gz
mkdir /opt/jdk
tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk
update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_25/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_25/bin/javac 100
New versions are installed and set up in the same manner, with a higher priority number. Old versions may safely be removed:
update-alternatives --remove java /opt/jdk/jdk1.8.0_25/bin/java
update-alternatives --remove javac /opt/jdk/jdk1.8.0_25/bin/javac
rm -rf /opt/jdk/jdk1.8.0_25
We can view the linked java and choose between multiple java installs with update-alternatives --display java
and update-alternatives --config java