Installation of JAVA 8 ( JDK 8u45) on Linux Systems

Installation of JAVA 8

Java 8 is known for cross platform availability developed by Sun Micro systems in 1995. It is fast, secure and reliable nature. Linux distribution comes with other version of Java called OpenJDK which is an open source implementation of Java application. Installation of JAVA 8 is explained in this manual.

To install Java 8 in Linux

To verify the version of installed Java

[root@linuxhelp~]# java -version
java version " 1.7.0_75" 
OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-2)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)

To make a directory location to install Java

[root@linuxhelp~]# mkdir /opt/java & &  cd /opt/java

To download Java (JDK) 8u45

Download source tarball files for your system architecture from official Java download page.

The source tarball file-names are as follows

jdk-8u45-linux-i586.tar.gz [For 32-bit Systems]
jdk-8u45-linux-x64.tar.gz [For 64-bit Systems]

You can also use wget command to download files directly into the /opt/java directory.

--------------- For 32-bit Systems ---------------

[root@linuxhelp~]# cd /opt/java
[root@linuxhelp~]# wget --no-cookies --no-check-certificate --header " Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F  oraclelicense=accept-securebackup-cookie"  " http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-i586.tar.gz" 


--------------- For 64-bit Systems --------------

[root@linuxhelp~]# cd /opt/java
[root@linuxhelp~]# wget --no-cookies --no-check-certificate --header " Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2

To extract the tarball

Use tar with zxvf options command to extract the tarball.

[root@linuxhelp~]# tar -zxvf jdk-8u45-linux-i586.tar.gz        [For 32-bit Systems]
[root@linuxhelp~]# tar -zxvf jdk-8u45-linux-x64.tar.gz        [For 64-bit Systems]

To move to the extracted directory

update-alternatives is the command used to move to the extracted directory.

[root@linuxhelp~]# cd jdk1.8.0_45/
[root@linuxhelp~]# update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.0_45/bin/java 100  
[root@linuxhelp~]# update-alternatives --config java

To update javac (java compiler) alternatives

[root@linuxhelp~]# update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.8.0_45/bin/javac 100
[root@linuxhelp~]# update-alternatives --config javac

To update jar alternatives

[root@linuxhelp~]# update-alternatives --install /usr/bin/jar jar /opt/java/jdk1.8.0_45/bin/jar 100
[root@linuxhelp~]# update-alternatives --config jar

To Set up Java Environment Variables

[root@linuxhelp~]# export JAVA_HOME=/opt/java/jdk1.8.0_45/    
[root@linuxhelp~]# export JRE_HOME=/opt/java/jdk1.8.0._45/jre     
[root@linuxhelp~]# export PATH=$PATH:/opt/java/jdk1.8.0_45/bin:/opt/java/jdk1.8.0_45/jre/bin

To verify the Java version

[root@linuxhelp~]# java -version
java version " 1.8.0_45" 
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

if OpenJDK is not used then you can remove using the following command


[root@linuxhelp~]# apt-get remove openjdk-* 
Tag : Java
FAQ
Q
what is the purpose of using alternatives command while installing java on a linux machine
A
It can maintain multiple versions of java and allows us to easily switch between them
Q
How to enable javascript in chrome web browser
A
open chrome ==> settings ==> search javascript ==> enable javascript
Q
How to compile a java code on linux machie using command
A
javac filename.java
Q
No Java Runtime Environment (JRE) was found on this system
A
check wheather JRE is properly installed if yes and also check for the proper parth for environment variable is set or not
Q
java command not found
A
use env command to check wheater the java environment variable is present or not