Saturday, August 31

Install JAVA on CentOS or RHEL 5/6

Step by Step Installation JAVA on CentOS or RHEL 5&6

     Use these steps to Install JAVA on Redhat or CentOS 5&6

Step 1: 

    Download latest version of java

   If you are using terminal  (Command Mode)

  [root@localhost ~]# cd /opt/

  [root@localhost opt]# wget

  Extract downloaded archive using following command.

   [root@localhost opt]# tar -xvzf  jdk-7u25-linux-  i586.tar.gz?AuthParam=1377944382_824ed437096a64593579b2d07b8e242e

   [root@localhost opt]#  ls -l
     drwxr-xr-x  8 uucp  143 4096 Jun  6 09:53 jdk1.7.0_25

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.  

   [root@localhost opt]# cd /opt/jdk1.7.0_25/
   [root@localhost opt]# alternatives --install /usr/bin/java java /opt/jdk1.7.0_25/bin/java 2
   [root@localhost opt]#alternatives --config java

         There are 3 programs which provide 'java'.

         Selection    Command
             1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
             2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
             3           /opt/jdk1.7.0_25//bin/java

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

  Now you have successfully configured java in your system. Go to next step to check current installed version.

Step 3:
    Check Version of JAVA .
    [root@localhost ~]# 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
                   [root@localhost opt]# export JAVA_HOME=/opt/jdk1.7.0_25

  •   Setup JRE_HOME Variable
                   [root@localhost opt]# export JRE_HOME=/opt/jdk1.7.0_25/jre
  •   Setup PATH Variable
               [root@localhost opt]# export PATH=$PATH:/opt/jdk1.7.0_25/bin:/opt/jdk1.7.0_25/jre/bin

 You can follow above steps to install multiple version of java as same time,  but you can use only one version at a time.

1 comment:

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training JavaEE Training in Chennai Java EE Training in Chennai


:: Linux - Legends ::