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:
http://java.com/en/download/installed.jsp
Verified Java Version
Congratulations!
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:
/usr/lib/jvm/java-7-oracle/bin/javaws

For complete reference see:
http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

No comments: