Saturday, 23 February 2013

How to install & upgrade JRE on Red Hat Linux

If you are connected to RHN (Red hat Network) then it is pretty easy to download & install the latest version of Java. You just need to type the following command in the terminal (as superuser)

yum install java-1.7.0-openjdk*

What if you have to install it offline or manually without using yum. Here are the steps:
1. Go to oracle site & download the latest package. Here I am using 64 bit package & also download the .bin package (not rpm.bin or any other).
2. Save the package jre-<version>.bin file to /opt directory.
3. Change the permission of the file (Make it executable). Run following command in the terminal (as superuser)

    chmod 777 jre-<version>.bin

4. Now install the jre package. Run the following command in terminal.

    ./jre-<version>.bin

or alternatively you can run:

    /bin/sh jre-<version>.bin

This command will install jre & create a directory in /opt (or in any other directory if you are installing somewhere other than /opt). Directory name will be jre<version>

5. Now run alternatives command:

   alternatives --install /usr/bin/java java /opt/jre<version>/bin/java 1

6. Now run command:

    alternatives --config java

Now make the latest version as default for the system.

7. Check the java version:

    java -version

It should show the latest version.

8. Check the status & java installation directories:

    alternatives --display java

You will get a message that java status is manual & it will also show the /opt directories where java is installed.

9. Now to set Java environmental variables, you can create a file in /etc/profile.d
    file name - java.sh
    Absolute path: /etc/profile.d/java.sh
    file content:

      export JAVA_HOME="/opt/jre-<version>/bin"
    export JAVA_PATH="$JAVA_HOME"
    export PATH="$PATH:$JAVA_HOME"

save the file.
10. Run the following command:

    source /etc/profile.d/java.sh
    


1 comment: