Every Time I set up an Oracle Linux server, I ask myself, how have I done it last time ...
1. Check which Java Version (JDK7, JDK8, ...) is certified with your software.
e.g. Oracle Fusion Middleware supported system configurations:
http://www.oracle.com/technology/software/products/ias/files/fusion_certification.html
2. Check support policy, esp. end of life for your desired Java Version
http://www.oracle.com/technetwork/java/javase/downloads/eol-135779.html
3. Download JDK
http://www.oracle.com/technetwork/java/javase/downloads/index.html
4. Install JDK
# ls -l jdk*
-rw-r--r--. 1 oracle oinstall 126679286 Jan 9 13:01 jdk-7u71-linux-x64.rpm
-rw-r--r--. 1 oracle oinstall 142191827 Jan 9 13:06 jdk-8u25-linux-x64.rpm
# rpm -Uhv jdk-7u71-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
5. Check Java Version
# java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
If this is your expected Java Version - fine! Your are done!
If you still have a pointer to an older version, move on ...
...
6. A non expected Java Version is present? lets say, JDK8 is still present, but you need to move back to JDK7
# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
7. Check Java install locations
# ls -l /usr/java/
total 8
lrwxrwxrwx. 1 root root 16 Jan 9 13:24 default -> /usr/java/latest
drwxr-xr-x. 8 root root 4096 Jan 9 13:49 jdk1.7.0_71
drwxr-xr-x. 9 root root 4096 Jan 9 13:40 jdk1.8.0_25
lrwxrwxrwx. 1 root root 21 Jan 9 13:40 latest -> /usr/java/jdk1.8.0_25
8. Make use of alternatives system to switch between versions
8.1 Syntax of alternatives
# /usr/sbin/alternatives
alternatives version 1.3.49.3 - Copyright (C) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.
usage: alternatives --install
[--initscript]
[--slave ]*
alternatives --remove
alternatives --auto
alternatives --config
alternatives --display
alternatives --set
common options: --verbose --test --help --usage --version
--altdir --admindir
8.2 Register your JDKs for alternatives
usage: alternatives --install
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_71/bin/java 17071
(where priority represents 17071 for jdk1.7.0_71)
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_25/bin/java 18025
(where priority represents 18025 for jdk1.8.0_25)
8.3 Now to switch between the versions
8.3.1 Check current java version, again
# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
8.3.2 Change the current java version
# /usr/sbin/alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/java/jdk1.7.0_71/bin/java
*+ 2 /usr/java/jdk1.8.0_25/bin/java
Enter to keep the current selection[+], or type selection number: 1
8.3.3 Check your current java version has changed
# java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
9. Keep your path JDK dynamic
The idea is, when you install for example WebLogic Server, to use a dynamic location to your JDK.
I do this with a symbolic link.
I have a folder /opt/oracle/java where I create a symbolic link, that points to the jdk.
As normal user I create the symbolic link:
$ ln -s /usr/java/jdk1.8.0_25 /opt/oracle/java/java
When an updated jdk version in available, after install I only change the symbolic link:
$ rm /opt/oracle/java/java
$ ln -s /usr/java/jdk1.8.0_31 /opt/oracle/java/java
For the WebLogic Server, the path to java will remain. No reconfiguration is needed.
So I only have to restart the WebLogic Server to use the latest JDK.
10. Tidy up! - delete out of date JDKs
10.1 Remove rpm
To delete the out-of-date versions of the JDK:
Query for all installed JDK rpms:
# rpm -aq | grep -i jdk
jdk1.8.0_31-1.8.0_31-fcs.x86_64
jdk-1.7.0_85-fcs.x86_64
jdk1.8.0_60-1.8.0_60-fcs.x86_64
In this example, I need to remove the jdk1.8.0_31:
# rpm -e jdk1.8.0_31-1.8.0_31-fcs
Check that the rpm has been deleted:
# rpm -aq | grep -i jdk
jdk-1.7.0_85-fcs.x86_64
jdk1.8.0_60-1.8.0_60-fcs.x86_64
10.2 De-register the java alternatives entry
Now we need to de-register the jdk in the alternatives configuration:
Current alternatives configuration:
# /usr/sbin/alternatives --config java
There are 3 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/java/jdk1.7.0_75/bin/java
2 /usr/java/jdk1.8.0_31/bin/java
*+ 3 /usr/java/jdk1.8.0_60/jre/bin/java
We need to remove selection No 2:
# alternatives --remove java /usr/java/jdk1.8.0_31/bin/java
Check again:
# /usr/sbin/alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/java/jdk1.7.0_75/bin/java
*+ 2 /usr/java/jdk1.8.0_60/jre/bin/java
Enter to keep the current selection[+], or type selection number: 2
Voilà!
1. Check which Java Version (JDK7, JDK8, ...) is certified with your software.
e.g. Oracle Fusion Middleware supported system configurations:
http://www.oracle.com/technology/software/products/ias/files/fusion_certification.html
2. Check support policy, esp. end of life for your desired Java Version
http://www.oracle.com/technetwork/java/javase/downloads/eol-135779.html
3. Download JDK
http://www.oracle.com/technetwork/java/javase/downloads/index.html
4. Install JDK
# ls -l jdk*
-rw-r--r--. 1 oracle oinstall 126679286 Jan 9 13:01 jdk-7u71-linux-x64.rpm
-rw-r--r--. 1 oracle oinstall 142191827 Jan 9 13:06 jdk-8u25-linux-x64.rpm
# rpm -Uhv jdk-7u71-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
5. Check Java Version
# java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
If this is your expected Java Version - fine! Your are done!
If you still have a pointer to an older version, move on ...
...
6. A non expected Java Version is present? lets say, JDK8 is still present, but you need to move back to JDK7
# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
7. Check Java install locations
# ls -l /usr/java/
total 8
lrwxrwxrwx. 1 root root 16 Jan 9 13:24 default -> /usr/java/latest
drwxr-xr-x. 8 root root 4096 Jan 9 13:49 jdk1.7.0_71
drwxr-xr-x. 9 root root 4096 Jan 9 13:40 jdk1.8.0_25
lrwxrwxrwx. 1 root root 21 Jan 9 13:40 latest -> /usr/java/jdk1.8.0_25
8. Make use of alternatives system to switch between versions
8.1 Syntax of alternatives
# /usr/sbin/alternatives
alternatives version 1.3.49.3 - Copyright (C) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.
usage: alternatives --install
[--initscript
[--slave
alternatives --remove
alternatives --auto
alternatives --config
alternatives --display
alternatives --set
common options: --verbose --test --help --usage --version
--altdir
8.2 Register your JDKs for alternatives
usage: alternatives --install
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_71/bin/java 17071
(where priority represents 17071 for jdk1.7.0_71)
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_25/bin/java 18025
(where priority represents 18025 for jdk1.8.0_25)
8.3 Now to switch between the versions
8.3.1 Check current java version, again
# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
8.3.2 Change the current java version
# /usr/sbin/alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/java/jdk1.7.0_71/bin/java
*+ 2 /usr/java/jdk1.8.0_25/bin/java
Enter to keep the current selection[+], or type selection number: 1
8.3.3 Check your current java version has changed
# java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
9. Keep your path JDK dynamic
The idea is, when you install for example WebLogic Server, to use a dynamic location to your JDK.
I do this with a symbolic link.
I have a folder /opt/oracle/java where I create a symbolic link, that points to the jdk.
As normal user I create the symbolic link:
$ ln -s /usr/java/jdk1.8.0_25 /opt/oracle/java/java
When an updated jdk version in available, after install I only change the symbolic link:
$ rm /opt/oracle/java/java
$ ln -s /usr/java/jdk1.8.0_31 /opt/oracle/java/java
For the WebLogic Server, the path to java will remain. No reconfiguration is needed.
So I only have to restart the WebLogic Server to use the latest JDK.
10. Tidy up! - delete out of date JDKs
10.1 Remove rpm
To delete the out-of-date versions of the JDK:
Query for all installed JDK rpms:
# rpm -aq | grep -i jdk
jdk1.8.0_31-1.8.0_31-fcs.x86_64
jdk-1.7.0_85-fcs.x86_64
jdk1.8.0_60-1.8.0_60-fcs.x86_64
In this example, I need to remove the jdk1.8.0_31:
# rpm -e jdk1.8.0_31-1.8.0_31-fcs
Check that the rpm has been deleted:
# rpm -aq | grep -i jdk
jdk-1.7.0_85-fcs.x86_64
jdk1.8.0_60-1.8.0_60-fcs.x86_64
10.2 De-register the java alternatives entry
Now we need to de-register the jdk in the alternatives configuration:
Current alternatives configuration:
# /usr/sbin/alternatives --config java
There are 3 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/java/jdk1.7.0_75/bin/java
2 /usr/java/jdk1.8.0_31/bin/java
*+ 3 /usr/java/jdk1.8.0_60/jre/bin/java
We need to remove selection No 2:
# alternatives --remove java /usr/java/jdk1.8.0_31/bin/java
Check again:
# /usr/sbin/alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/java/jdk1.7.0_75/bin/java
*+ 2 /usr/java/jdk1.8.0_60/jre/bin/java
Enter to keep the current selection[+], or type selection number: 2
Voilà!