Installation Guide: Oracle JDK 7 on Ubuntu 12.04 LTS

This tutorial teaches you command based way of installing JDK from official sources. Users can use unofficial PPAs to install JDK directly but that can be dangerous.

What is JDK?
Java Development Kit. Includes a complete JRE plus tools for developing, debugging, and monitoring Java applications.

Is there any PPA for the same?
There is no official PPA for this from Oracle / Ubuntu. Though unofficial PPA is available at

JDK Version: JDK 7
FileName: jdk-7u51-linux-x64.tar.gz
Download Page: Java SE Development Kit 7 Downloads

Let’s extract the downloaded content and put it in the right place.

tar -xvf jdk-7u51-linux-x64.tar.gz
mkdir -p /usr/lib/jvm
mv ./jdk1.7.0_51/ /usr/lib/jvm/jdk1.7.0_51/

Let’s create some symbolic links:

sudo update-alternatives –install “/usr/bin/java” “java” “/usr/lib/jvm/jdk1.7.0_51/bin/java” 1
sudo update-alternatives –install “/usr/bin/javac” “javac” “/usr/lib/jvm/jdk1.7.0_51/bin/javac” 1
sudo update-alternatives –install “/usr/bin/javaws” “javaws” “/usr/lib/jvm/jdk1.7.0_51/bin/javaws” 1


Let’s ensure right users have the right permission:

sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.7.0

i: 755 provides only read and execute rights to non-owner.