Installing the Latest Java 8 In Ubuntu
To listen to some security experts, java is a bug ridden cesspool that gives attackers complete access to your machine and data. They're probably right. Unfortunately it's also a necessary evil for many of us.
Please, make absolutely sure you update Java.
Having an outdated Java is the worst thing you can do. Unfortunately the easy ways of installing Java in Ubuntu Linux have gone the way of the dodo, it seems. The PPA repository that offers Java 8 from webupd8 never seems to work for me anymore.
Step 1: Download the JDK.
First, go to Java 8 Download Page and grab the latest version of the 64 bit Java SE Development Kit 8. As I'm writing this, version 8u73 is the latest stable, so I'm downloading "jdk-8u73-linux-x64.tar.gz" from the top list of downloads.
Once downloaded, run the following commands:
tar -zxvf jdk-8u* sudo mkdir /usr/lib/jvm sudo mkdir /usr/lib/jvm/java-8-oracle cd jdk1.8.0* sudo cp -R * /usr/lib/jvm/java-8-oracle/ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-8-oracle/jre/bin/java" 1 sudo update-alternatives --set java /usr/lib/jvm/java-8-oracle/jre/bin/java sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java-8-oracle/jre/bin/javaws" 1 sudo update-alternatives --set javaws /usr/lib/jvm/java-8-oracle/jre/bin/javaws sudo update-alternatives --install "/usr/bin/jjs" "jjs" "/usr/lib/jvm/java-8-oracle/jre/bin/jjs" 1 sudo update-alternatives --set jjs /usr/lib/jvm/java-8-oracle/jre/bin/jjs
Once complete, check your java version by running:
java -version
It should report "1.8.0_73" or whatever the latest is that you just installed.
Updating it later
Every so often, make sure to grab the latest version from Oracle. It's likely another critical bug has been patched in the past week, so download it again. To update your install it's just a subset of the commands. First, close everything that uses Java. Then run just the following after downloading the latest:
tar -zxvf jdk-8u* cd jdk1.8.0* sudo cp -R * /usr/lib/jvm/java-8-oracle/ java -version
That should show you now running the latest version.
Updating is important
I can't stress this enough - since your package manager will not be regularly updating your Java install, you must now manually check every so often and install the latest. If you hear of a new Java bug, immediately update, otherwise make sure to check at least once a month.