January 31, 2012

How to install Oracle JDK on Ubuntu 11 from repository.

With Oracle the acquisition of Sun the Oracle have retired the "Operating System Distributor License for Java" (JDL) and the only available JDK release will be the OpenJDK. I had previously some bad experience with the OpenJDK and I prefer to use the official Oracle version of JDK, but I don't want to install the JDK binaries manually – we are using Ubuntu! But the webupd8.org team have been nice to published the binaries in a Personal Package Archives (PPA) and so far I have no problem using it, so I can warmly recommend using it.

To install:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo mkdir -p /usr/lib/mozilla/plugins #just in case, this will be added to the package in the next version
sudo apt-get install oracle-jdk7-installer

And to uninstall:
sudo apt-get remove oracle-jdk7-installer

And to verify your installation:
java -version
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)

And to verify the web browser installation:
Verified Java Version
You have the recommended Java installed (1.7.0_02).

And with maven 2:
mvn -version
Java version: 1.7.0_02
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.0.0-15-generic" arch: "amd64" Family: "unix"

Java Web Start
The only thing that did not work out of the box was the Java Web Start. To fix that open JNLP file link and when asked for application, brows to:

For complete reference see:


Gustavo A. Arellano said...

Hi, Thanks for the info.

Just one question:

What about the original OpenJDK that comes with Ubuntu? Is it automatically removed by installing the Oracle JDK?

Thanks, in advance from méxico.


Magnus K Karlsson said...

No, you have to remove the OpenJdk manually, with
sudo apt-get purge openjdk

Derek said...

And that's the way it _should_ be. I've just come across two posts suggesting the first thing you should do is purge openjdk. Which will proceed to remove any package with a dependency on a jre.