Install JAVA 7 on CentOS/Fedora/RHEL

Install Java 7
Java is a high-level, class-based, object-oriented programming language. This article will help you to know how to install JAVA 7 on CentOS/Fedora/RHEL.

Some developers can do magics with Java. But even they use to have issues while installing Java in Linux. Here are the easy steps to install Java in your CentOS/Fedora/RHEL system.

Note: If you want to install Java 8, follow the tutorial – Install JAVA 8 on CentOS/Fedora/RHEL

 

1) Download the Source Package

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

For 32 Bit :

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/7u71-b14/jdk-7u71-linux-i586.tar.gz"

 

For 64 Bit :

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/7u71-b14/jdk-7u71-linux-x64.tar.gz"

 

2) Extract the archive file

For 32 Bit :

tar -xvf jdk-7u71-linux-i586.tar.gz

 

For 64 Bit :

tar -xvf jdk-7u71-linux-x64.tar.gz

 

3 ) Install and configure Java, Javac, and Jar

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

cd /opt/jdk1.7.0_71/
alternatives --install /usr/bin/java java /opt/jdk1.7.0_71/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.7.0_71/bin/javac 2
alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_71/bin/jar 2
alternatives --set javac /opt/jdk1.7.0_71/bin/javac
alternatives --set jar /opt/jdk1.7.0_71/bin/jar

 

4) Setup Environment Variables

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

export JAVA_HOME=/opt/jdk1.7.0_71
export JRE_HOME=/opt/jdk1.7.0_71/jre
export PATH=$PATH:/opt/jdk1.7.0_71/bin:/opt/jdk1.7.0_71/jre/bin

 

5) Check and Verify

java -version

 

So that’s how you install JAVA 7 on CentOS/Fedora/RHEL.

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

Linux Management Services

Focus on your business, and let us take care of your Linux Servers!
From what you are reading, it seems you are interested in Linux and related technologies. If you have a moment to spare, please take a look at our Linux Management Services plan, which might interest you even more!
Linux Management Plan

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

ServerHealers uses cookies.