Oracle Java has been removed from the official Ubuntu repositories due to the new Java license. If you need to use Oracle Java instead of OpenJDK in Ubuntu, this simple tutorial will show you how to install Oracle Java (JDK which includs JRE) 6 / 7 / 8 in Ubuntu 13.04 using the ppa repository.

The Webupd8 Team created a ppa with packages which automatically downloads Oracle Java JDK from its official website and installs it on your computer. They are oracle-java6-installer, oracle-java7-installer, and oracle-java8-installer. The ppa supports for Ubuntu 13.04, 12.10, 12.04 and 10.04.

To get started, hit Ctrl+Alt+T to open a terminal window for running commands.

Remove OpenJDK first if installed by this command:

sudo apt-get purge openjdk*

Then add the Webupd8 Team PPA repository and then reload the packages:

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

Now, install Oracle Java:

sudo apt-get install oracle-java7-installer

Or, change the number 7 to 6 or 8 to install Java6 or Java8.

After installation, run command to check if it was successful:

java -version

It should return something like this:

java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode)

(Optional) To remove Oracle Java, run this command in terminal (change the package name to yours):

sudo apt-get remove oracle-java7-installer