Install JAVA 8 on CentOS/Fedora/RHEL

Hope our Java 7 installation tutorial was helpful to you. So after Java 7, here is our easy tutorial to install Java 8 in your CentOS/Fedora/RHEL system.

1) Download the Source Package

You can download latest Java 8 packages from here ( At the time of writing, the latest version is JDK 8u25, so we will be installing that version )

For 32 Bit :

cd /opt
wget --no-cookies --no-check-certificate --header "Cookie:; oraclelicense=accept-securebackup-cookie" ""

For 64 Bit :

cd /opt 
wget --no-cookies --no-check-certificate --header "Cookie:; oraclelicense=accept-securebackup-cookie" ""

2) Extract the archive file

For 32 Bit :

tar -xvf jdk-8u25-linux-i586.tar.gz

For 64 Bit :

tar -xvf jdk-8u25-linux-x64.tar.gz

3 ) Install and configure Java, Javac and Jar

We will be using “alternative” command to install and configure java, javac and jar

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

( alternatives –config java command will let you choose the desired Java version if you have multiple versions installed in your system. Make sure you choose the version we are installing )

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

4) Setup Environment Variables

If you are installing Java based applications such as Tomcat, you may have to configure the following environment variables.

export JAVA_HOME=/opt/jdk1.8.0_25
export JRE_HOME=/opt/jdk1.8.0_25/jre
export PATH=$PATH:/opt/jdk1.8.0_25/bin:/opt/jdk1.8.0_25/jre/bin

5) Check and Verify

java -version

So that’s how you Install JAVA 8 on CentOS/Fedora/RHEL


Please enter your comment!
Please enter your name here