Install Oracle JDK on Oracle Linux
07 May 2013 by martin
I could't find a reference to this in the JDK Install instructions so I thought I'd make a note of it here.
I installed the latest Oracle JDK on Oracle Linux using the RPM downloaded from here, but when I checked the version number I was still getting OpenJDK.
# rpm -ivh jdk-7u21-linux-x64.rpm
...
# java -version
java version "1.7.0_19"
OpenJDK Runtime Environment (rhel-2.3.9.1.0.1.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
The solution is to use the RedHat "alternatives" utility.
1) Register the newly installed Oracle JDK with "alternatives"
# alternatives --install /usr/bin/java java /usr/java/default/bin/java 2
2) Set the new JDK to be the default
# alternatives --config java
Choose the option that represents the Java version you require.