Thursday, 10 October 2013

If you really need to use Oracle (ex Sun) Java instead of OpenJDK in Ubuntu, here's an easy way to do it: a PPA repository to install and keep your computer up to date with the latest Oracle Java 7 (Java JDK which includes JRE).

Oracle JDK7 itself is not hosted in the PPA because that's not allowed by the new Java license (which is also the reason why it has been removed from the official Ubuntu repositories); the package in the PPA automatically downloads Oracle Java JDK 7 from its official website and installs it on your computer, just like the flashplugin-installer package does.

This package provides Oracle Java JDK 7 (which includes Java JDK, JRE and the Java browser plugin). However, you can't only install Oracle JRE - the PPA only provides the full Oracle JDK7 package.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

The package installs all the Java binaries, so you can also try "javac -version" which should return "javac 1.7.0_10" and so on). The current JDK version in the PPA is Oracle Java 7 Update 10 (7u10).

If for some reason, the Java version in use is not 1.7.0, you can try to run the following command:

sudo update-java-alternatives -s java-7-oracle

the installer requires you accept the Oracle license before the installation begins. This is only required once.

sudo echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections

To automatically set up the Java 7 environment variables, you can install the following package:
sudo apt-get install oracle-java7-set-default

No comments:

Post a Comment