Install and set Java on Ubuntu 14.04 LTS with tar ball file

In this tutorial we will learn , how to install and set Java on Ubuntu 14.04 LTS with tar ball. Currently on Oracle official site the .deb package is not available. We will first download the JDK tar package and then simply set the environment.

Steps to set Java environment is same with Debian, Ubuntu, RHEL, CentOS. We have already written post on setting java envinonment on RHEL/CentOS .

Step 1 : Download the Jdk package from Oracle site. As per your operating system architecture (32 or 64 bit) download the appropriate package.

Download link : Download the latest Jdk package from Oracle official site.

Java

Step 2 : Now with the help of scp transfer the downloaded jdk package into linux system.

Windows user can use winscp to transfer file into Linux system.

Step 3 : Now login into your Ubuntu / Debian system.

Step 4 : Now switch to superuser.

sudo su -

Step 5: With the help of tar command, decompress the jdk package.

Replace jdk-8u40-linux-x64.tar.gz with the jdk package name which you have downloaded.
Because of -C switch , the file will be extracted to /opt .

tar -xvzf jdk-8u40-linux-x64.tar.gz -C /opt

Step 6 : To make available the java command with latest version. We will edit /etc/profile file.

Edit the /etc/profile .

vi /etc/profile

Add the below given line at the bottom of /etc/profile file.
Note: Find the correct path of jdk file extarcted in /opt and replace it in below given lines.

export JAVA_HOME=/opt/jdk1.8.0_40/
export PATH=/opt/jdk1.8.0_40/bin:$PATH

Step 7: Now use the source command to load the Java Environment variable without system restart.

source /etc/profile

Step 8: Now check the Java version and java path.

Run the below given command to get java version.

root@localhost:~# java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
root@localhost:~#

Also use the below given coomand to verify.

echo $JAVA_HOME

echo $PATH