Install Java 8 (Jdk 8u31) on CentOS/RHEL 7/6/5 & Fedora


Now Java SE Development Kit 8 version is available to download. It released on Mar,18 2014 with lot of featured enhancements.

This guide will help you to install Java 8 or Java 8 update on your system (CentOS/RHEL 7/6/5 & Fedora).

read our instructions and download java from Linux command line.

Download latest Java archive

java for linux

You can download Java SE development kit 8 from official site download page or use the following command and download it from shell.

For 64Bit

# cd /opt/
# 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/8u31-b13/jdk-8u31-linux-x64.tar.gz"

# tar xzf jdk-8u31-linux-x64.tar.gz

For 32Bit

# cd /opt/
# 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/8u31-b13/jdk-8u31-linux-i586.tar.gz"

# tar xzf jdk-8u31-linux-i586.tar.gz

Install Java using Alternatives command

After extracting archive file, install it via alternatives command (available in chkconfig package).

 cd /opt/jdk1.8.0_31/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_31/bin/java 2
# alternatives --config java


There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /opt/jdk1.8.0/bin/java
 + 2           /opt/jdk1.8.0_25/bin/java
   3           /opt/jdk1.8.0_31/bin/java

Enter to keep the current selection[+], or type selection number: 3

Now JAVA 8 has been successfully installed on your computer. Then setup javac and jar commands path via alternatives command (We strongly recommended).

# alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_31/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_31/bin/javac 2
# alternatives --set jar /opt/jdk1.8.0_31/bin/jar
# alternatives --set javac /opt/jdk1.8.0_31/bin/javac

How to check installed java version

Easily check installed version of java using the following command:

# java -version 

java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

Now configure environment variables

Many Java based apps uses environment variables to work. You can easily setup Java environment variables via following commands:

For JAVA_HOME Variable setup

# export JAVA_HOME=/opt/jdk1.8.0_31

For JRE_HOME Variable setup

# export JRE_HOME=/opt/jdk1.8.0_31/jre

For PATH Variable setup

# export PATH=$PATH:/opt/jdk1.8.0_31/bin:/opt/jdk1.8.0_31/jre/bin
12:38 pm