Wednesday, 6 November 2013

Install JAVA on CentOS 5/6 or RHEL 5/6

Step 1: Download Archive File

Download latest version of java from

# cd /opt/ 
# wget

After completing download, Extract archive using following command.

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

Step 2: Install JAVA using Alternatives

After extracting java archive file, we just need to setup to use newer version of java using alternatives. Use the following commands to do it.

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

 There is 1 program that provides 'java'. 

 Selection                                       Command 

 *+ 1                                             /opt/jdk1.7.0_25/bin/java 

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

Step 3: Check Version of JAVA .

# java -version
java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode)

Step 4: Setup Environment Variables

Most of java based application’s uses environment variables to work. Use following commands to setup it.
Setup JAVA_HOME Variable
# export JAVA_HOME=/opt/jdk1.7.0_25

Setup JRE_HOME Variable
# export JRE_HOME=/opt/jdk1.7.0_25/jre

Setup PATH Variable
# export PATH=$PATH:/opt/jdk1.7.0_25/bin:/opt/jdk1.7.0_25/jre/bin

No comments:

Post a Comment