Monday, March 16, 2015

Ubuntu 14.04 | Install Oacle JDK | Step by Step

Ubuntu users,... this article will help you to Install Oracle JAVA 7/8 (JDK/JRE) on Ubuntu 14.04 LTS, 12.04 LTS.

There are two ways to install JDK in ubuntu.

1) Using PPA.
2) Manual installation.

1) Using PPA.

We can use WebUpd8 PPA (this will download the required files from Oracle).

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

apt-get install will install the latest version available, now verify your Installed Java version using below command

$ java -version 
java version "1.7.0_56"

Now set environment variables for the installed JAVA version.

$ sudo update-alternatives --config java

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

2) Manual installation.
In a manual installation we dont actually install java. The tar.gz provided by Oracle, we just extract those files to a location we want and add them to our path.

So here is the manual process:

1) Download a .tar.gz from Oracle official website

2) Extract it to somewhere (/home/chirag/Downloads/);

3) Move the extracted folder to /usr/lib/jvm.
(This is not mandatory but it is the default place where Java runtime software is usually installed.)

 sudo mv /path/to/jdk /usr/lib/jvm/oracle_jdk7  

4) Now configure ~/.bashrc to set the environment variable manually.

 sudo gedit ~/.bashrc

and add below lines to the file - Save and close.
export J2SDKDIR=/usr/lib/jvm/oracle_jdk7  
export J2REDIR=/usr/lib/jvm/oracle_jdk7/jre  
export PATH=$PATH:/usr/lib/jvm/oracle_jdk7/bin:/usr/lib/jvm/oracle_jdk7/db/bin:/usr/lib/jvm/oracle_jdk7/jre/bin  
export JAVA_HOME=/usr/lib/jvm/oracle_jdk7  
export DERBY_HOME=/usr/lib/jvm/oracle_jdk7/db

Done! You are now ready to use java.


  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.

  2. It seems you are so busy in last month. The detail you shared about your work and it is really impressive that's why i am waiting for your post because i get the new ideas over here and you really write so well.

    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training
    Selenium training in bangalore