Easy way to install Oracle Java on Ubuntu

The default Java packages (JRE and JDK) on Ubuntu come from the OpenJDK project. Sometimes we need to use specifically a Oracle Java SE Runtime (JRE) Environment or Oracle Java SE Development Kit (JDK) package on our Ubuntu Desktop or Ubuntu Server and a manual installation on paths like /opt or /usr/local paths isn’t a elegant or clean solution, other than that, you will not receive new package updates.

An easy way to install the Oracle JDK and the Oracle JRE and receive software updates of those packages is by add a repository with installation packages to our system with those instructions:

The following commands add the new apt repository and update the local list of packages:

Now you can choose a version to install, at the moment of this post was written there are Oracle Java 6, Oracle Java 7, Oracle Java 8 and Oracle Java 9 versions:

You don’t need to uninstall the OpenJDK packages that sometimes is needed by other packages as dependencies. Instead you can configure the system to use as default all the Java executables (e.g. javajavac, javadoc, javap and javaws) from a specific installed JRE or JDK with the following commands:

To list the installed Java packages:

To use a specific installed java package:

Now you confirm that the Java executables are used from the chosen Java package:


With those instructions, you will receive new versions of the Java packages through the normal software updates of your Ubuntu operation system.


Launchpad WebUpd8 team

Live Webcast Introducing Java EE 7

Live Webcast Introducing Java EE 7

Register here to join us for a live webcast Introducing Java EE 7! The Java EE 7 platform JSR has been approved, and we are now counting down the days to begin developing with many new Java EE features.

The event will run with live chat at two times:

Wednesday, June 12, 2013 / Thursday, June 13, 2013

  • 9 am PT / 12 pm ET / 5 pm London
  • 9 pm PT / 12 am ET (Thursday) / 2 pm Sydney (Thursday)

Spread the word!