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  
 
OR
$ 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  
OR
$ 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.


No comments:

Post a Comment