Moving from JDK 1.7 to JDK 1.8 on Ubuntu
This is what I do on debian - I suspect it should work on ubuntu (amend the version as required + adapt the folder where you want to copy the JDK files as you wish, I'm using /opt/jdk
):
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u71-b15/jdk-8u71-linux-x64.tar.gzsudo mkdir /opt/jdksudo tar -zxf jdk-8u71-linux-x64.tar.gz -C /opt/jdk/rm jdk-8u71-linux-x64.tar.gz
Then update-alternatives:
sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_71/bin/java 1sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_71/bin/javac 1
Select the number corresponding to the /opt/jdk/jdk1.8.0_71/bin/java
when running the following commands:
sudo update-alternatives --config javasudo update-alternatives --config javac
Finally, verify that the correct version is selected:
java -versionjavac -version
Just use these command lines:
sudo add-apt-repository ppa:webupd8team/javasudo apt-get updatesudo apt-get install oracle-java8-installer
If needed, you can also follow this Ubuntu tutorial.