Installing Oracle Java JDK/JRE on RedHat Linux


java-logo

Applies to:

  • RHEL v5 or newer

To the rest of us, the included OpenJDK shipped on our RHEL installer is more than enough. But for some peculiar reason, application vendors requires specific oracle’s java version, which is annoying.

The RPMs can be downloaded here. To install do:

[root@fragfest ~]# rpm -ivh jdk-7u65-linux-x64.rpm

If you already have installed OpenJDK, set the Oracle Java packages as an altetnative:

[root@fragfest ~]# alternatives --install /usr/bin/java java /usr/java/jre1.7.0_65/bin/java 2

To select the java that you have recently installed, do:

[root@fragfest ~]# alternatives --config java

On the next screen:

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
 + 1           /usr/java/jre1.7.0_65/bin/java
   2           /usr/java/jdk1.7.0_65/jre/bin/java
*  3           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

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

Select “1” to select the oracle java as /usr/bin/java.

Next, to set the path:

[root@fragfest ~]# export JRE_HOME=/usr/java/jdk1.7.0_65/jre/
[root@fragfest ~]# export JAVA_HOME=/usr/java/jdk1.7.0_65/
[root@fragfest ~]# export PATH=$PATH:/usr/java/jdk1.7.0_65/bin/:/usr/java/jdk1.7/jre/bin

To automatically load them on every login, add those line to your .bashrc file by doing:

[root@hqsoaapp1 ~]# vi .bashrc

your .bashrc should look like this:

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
export JRE_HOME=/usr/java/jdk1.7.0_65/jre/
export JAVA_HOME=/usr/java/jdk1.7.0_65/
export PATH=$PATH:/usr/java/jdk1.7.0_65/bin/:/usr/java/jdk1.7/jre/bin
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

Save. Now check your java version:

[root@fragfest ~]# java -version
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

If it’s similar to the above, then you have oracle’s java up and running.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s