Subject: Upgrade JDK to JDK 7u79
Author: AwsEC2
In response to: Set environment variable JAVA_HOME
Posted on: 04/20/2016 11:33:47 PM
Download JDK package
There are two packages available for Linux: .rpm and .gz. If you download the .rpm package, you can unwrap it with:
rpm -i jdk-7u79-linux-x64.rpm
[/cpde]
The following is to download .gz package directly unto the linux box.
[code]
# cd /opt
# wget --no-cookies --no-check-certificate
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F;
oraclelicense=accept-securebackup-cookie"
"http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz"
# tar xzf jdk-7u79-linux-i586.tar.gz
Now you should see an extra folder 'jdk1.7.0_79' under /opt/
Stop old servicesThe previous link can be found as:
# which java
/usr/bin/java
/usr/bin/java --> /etc/alternatives/java --> /usr/java/jdk1.6.0_34/bin/java
Now first stop all java apps which are running on this jre before we can install the new one.
# /env/tomcat/apache-tomcat-6.0.35/bin/shutdown.sh
# /etc/init.d/httpd stop
Install JDK Linkage
# /usr/sbin/alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 100
# /usr/sbin/alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 100
# /usr/sbin/alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 100
# /usr/sbin/alternatives --config java
There are 3 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
+ 2 /usr/java/jdk1.6.0_34/bin/java
3 /opt/jdk1.7.0_79/bin/java
Enter to keep the current selection[+], or type selection number: 3
You can verify the version by:
# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
Environment Settings
# vi /etc/profile
i -- insert
export JAVA_HOME=/opt/jdk1.7.0_79
Esc -- exit insert mode
dd -- delete current line
export JAVA_HOME=/usr/java/jdk1.7.0_79
:x -- save and exit vi
Finally, log off to let the changes take effect.
>
> On 08/28/2012 06:59:03 PM
AwsEC2 wrote:
After changing any environment settings, you have to log off to let the changes take effect.
Quick notes on vi:
1) Start vi
vi <filename>
2) Browse
:$ -- Last line
:0 -- First line
3) Insert
i <changes> Esc
4) Copy-Paste
yy -- copy current line
yNy -- copy N lines
p -- paste
5) Search
/<str> -- search for <str>
6) Exit vi:
:x -- to eXit (save+quit)
:q -- to quit
:q! -- to quit without save
References: