Install JAVA 7 (JDK 7u79) on RHEL 7/6/5, CentOS and Fedora


It is always better to use Sun Site to install Java because it is very easy when compared to install java from rpm files. Oracle has also released Java 8 too. Just follow the 4 steps given below to install Java in your system.

If you wish to download the Java 7. You can download it from the Official Website link given below.

Download Java 7 kit

java-oracle

STEP 1: DOWNLOAD JAVA ARCHIVE FOR JAVA 7:

Before installing Java we have to install Java archive. Download the Latest Java archive from the official Oracle website.

After the completion of Download, extract the archive within the  Commands.

FOR 64 BIT SYSTEM:

# 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/7u79-b15/jdk-7u79-linux-x64.tar.gz"

# tar xzf jdk-7u79-linux-x64.tar.gz

Use the above command for 64 bit system, Oops do you have 32 bit system? Don’t worry guys i have also listed the command for 32 bit system.

 

FOR 32 BIT SYSTEM:

# 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/7u79-b15/jdk-7u79-linux-i586.tar.gz"

# tar xzf jdk-7u79-linux-i586.tar.gz

 

 

Use the above command to install the java archive for 32 bit system.

if the wget command fails to work, then download java source terminal.

 

STEP 2: SET UP NEW VERSION :

After extracting the java archive file, set up the new version of the java using alternatives. Type the following command.

# cd /opt/jdk1.7.0_79/

# alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 2

# alternatives --config java

 

 

When you type the above command you will get a window which contains the following command.

  Selection    Command

-----------------------------------------------

*  1           /opt/jdk1.7.0_60/bin/java

 + 2           /opt/jdk1.7.0_72/bin/java

   3           /opt/jdk1.7.0_79/bin/java

 

 

 

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

# alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 2

# alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 2

# alternatives --set jar /opt/jdk1.7.0_79/bin/jar

# alternatives --set javac /opt/jdk1.7.0_79/bin/javac

From the above window press 3. Now it is required to set up jar and javac commands using the alternative command given below.

 

Now Java will be installed in your system.

 

STEP 3: CHECKING THE INSTALLED JAVA VERSION:

After the installation process, check the installed version using the below command.

# java -version

java version "1.7.0_79"

Java(TM) SE Runtime Environment (build 1.7.0_79-b15)

Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

 

 

STEP 4: CONFIGURATION OF ENVIRONMENT VARIABLE IN JAVA 7:

Java based applications mostly uses the environment variables, It is necessary to setup the environment variable. Add the following command to start up scripts like, ~/.bashrc or ~/.bash_profile.

SET UP THE JAVA_HOME VARIABLE FOR JAVA 7:

Type the following command to JAVA_HOME variable,

# export JAVA_HOME=/opt/jdk1.7.0_79

 

 

SETUP JRE_HOME VARIABLE FOR JAVA 7:

Type the following command to JRE_HOME variable.

# export JRE_HOME=/opt/jdk1.7.0_79/jre

 

 

SETUP PATH VARIABLE FOR JAVA 7:

Type the following command to set up the Path variable.

# export PATH=$PATH:/opt/jdk1.7.0_79/bin:/opt/jdk1.7.0_79/jre/bin

 

Hope that i have did good job to help you. You can install multiple version of the Java using the above command. But i hope it is not necessary because you can only use one version at a time.

If you wish to Install Java 8, the latest version then you can visit my previous post on it.

 

 

 

7:51 am