Ubuntu 12.04 LTS Oracle Java JDK Install

There are lots of ways to install the official Oracle JDK on Ubuntu 12.04 LTS, however I prefer to use the following PPA (Ubuntu Personal Package Archive) supplied by WEB UPD8. The beauty of this method is that it sorts out all the update-alternatives commands for you and you get automatic updates as when they are released.

So follow the instructions outlined in this guide to add the PPA. If you haven't got the add-apt-repository command then you can install it using:

sudo apt-get install python-software-properties

The PPA includes installers for JDK 6, 7 & 8:

user@client:~$ apt-cache search oracle-java
oracle-jdk7-installer - Oracle JDK7 Installer meta package
oracle-java7-installer - Oracle Java(TM) Development Kit (JDK) 7
oracle-java6-installer - Oracle Java(TM) Development Kit (JDK) 6
oracle-java8-installer - Oracle Java(TM) Development Kit (JDK) 8
oracle-java7-set-default - Set Oracle JDK 7 as default Java
oracle-java6-set-default - Set Oracle JDK 6 as default Java
oracle-java8-set-default - Set Oracle JDK 8 as default Java

Just install the version your after and let the package do the rest for you.