Last Updated: February 25, 2016
·
8.042K
· ihcsim

Installing Oracle Java 7 On Ubuntu 13.04/12.10/12.04

Reference: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html (all credits go to original authors.)

In case you need Oracle Java instead of OpenJDK in Ubuntu, here's how you can install it via a PPA:

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

Note that the PPA doesn't host Oracle Java 7 as this not allowed by the new Java license (which is also the reason why it has been removed from the official Ubuntu repositories in the first place). The package in the PPA simply downloads Oracle Java JDK 7 from its official website and installs it on your machine.

To test if the installation is completed successfully, execute:

java -version

If for some reasons, the Java installed is not version 1.7.x, execute the following command to force an update:

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

To automatically set up the Java 7 environment variables, install the following package:

sudo apt-get install oracle-java7-set-default