If you have RHEL 7 fresh installed machine, there must be
installed open java as the default java installation. If you want to change
java environment to oracle java 7, follow below commands,
First check existing java version,
[akila@localhost
u01]# java -version
It will give you the existing java version like below,
java
version "1.7.0_51"
OpenJDK
Runtime Environment (rhel-2.4.5.5.el7-x86_64 u51-b31)
OpenJDK
64-Bit Server VM (build 24.51-b03, mixed mode)
To
install oracle jdk, first you have to download it from oracle site,
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
or download it using wget command.
Locate
the downloaded file in a specific location, let’s name it as <location>.
Extract
downloaded tar file using tar command,
[akila@localhost
u01]# tar xzf jdk-7u60-linux-x64.ta
Now
install java using alternatives command,
[akila@localhost
u01]# alternatives --install /usr/bin/java java
<location>/jdk1.7.0_60/bin/java 2
[akila@localhost u01]# alternatives --config java
Now
you can check java version changed to oracle java 7,
[akila@localhost
u01]# java -version
java
version "1.7.0_60"
Java(TM)
SE Runtime Environment (build 1.7.0_60-b19)
Java
HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
Now
you have to set JAVA_HOME and add it to PATH,
[akila@localhost
u01]# export JAVA_HOME="<location>/jdk1.7.0_60"
[akila@localhost
u01]# JRE_HOME="<location>/jdk1.7.0_60/jre"
[akila@localhost
u01]# export PATH=$PATH: JAVA_HOME/bin: JAVA_HOME/jre/bin
Above
commands are only for temporarily. To make changes permanently, you have to
update .bash_profile
By
default .bash_profile file looks like below,
#
.bash_profile
#
Get the aliases and functions
if
[ -f ~/.bashrc ]; then
. ~/.bashrc
fi
#
User specific environment and startup programs
PATH=$PATH:$HOME/bin
export
PATH
Edit
the file like below,
# .bash_profile
#
Get the aliases and functions
if
[ -f ~/.bashrc ]; then
. ~/.bashrc
fi
#
User specific environment and startup programs
JAVA_HOME="/<location>/jdk1.7.0_60"
JRE_HOME="/<location>/jdk1.7.0_60/jre"
export
JAVA_HOME
export
JRE_HOME
PATH=$PATH:$HOME/bin:/
<location>/jdk1.7.0_60/bin:/ <location>/jdk1.7.0_60/jre/bin
export
PATH
Now
you have successfully installed java 7 in your RHEL/CentOS 7 machine
No comments:
Post a Comment