Issue
I started off with CentOS and OpenJDK 1.7
# java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
In order to run a specific application, I want to use Oracle's Java 1.6, provided from an RPM.
I copied the Oracle binary to a specific new directory:
# pwd
/oracleJava/jdk-6u45-linux-x64-rpm
I extracted the binary and it gave me the following files:
# ls
jdk-6u45-linux-amd64.rpm
sun-javadb-core-10.6.2-1.1.i386.rpm sun-javadb-javadoc-10.6.2-1.1.i386.rpm
sun-javadb-client-10.6.2-1.1.i386.rpm sun-javadb-demo-10.6.2-1.1.i386.rpm
sun-javadb-common-10.6.2-1.1.i386.rpm sun-javadb-docs-10.6.2-1.1.i386.rpm
I installed the RPM and the rpm utility believes that it installed properly: rpm -q jdk jdk-1.6.0_45-fcs.x86_64
# rpm -Uvh ./*.rpm
Preparing... ########################################### [100%]
package jdk-2000:1.6.0_45-fcs.x86_64 is already installed
# rpm -Uvh sun-javadb-*.rpm
[I omit the feedback because it generates a formatting error]
#
However, the Java version just shows 1.7 # java -version java version "1.7.0_25" OpenJDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64) OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
In other words, I was expecting the Oracle files to give me some new /java directory somewhere, with a new java executable that would return a different answer for "java -version"
I need that new directory so that I can set JAVA_HOME and use the 1.6 version of Java.
Helpful suggestions would be greatly appreciated. Thanks in advance.
Solution
The problem is that Oracle's RPMs are (wilfully IMO!) ignorant of the "alternatives" system.
Instead, they install stuff in a non-standard place (/usr/java) and then expect the user / system administrator to mess with the PATH variable ... by hand.
It is a nuisance!
So what has probably happened in your case is that your JDK / JRE has been installed in a subdirectory of /usr/java ... but since you haven't added the relevant bin
subdirectory to the front of your PATH
you are still picking up the OpenJDK tools via the java
command name.
You can fix this after the fact by using "alternatives" to configure and then select the Oracle commands. But it is messy, especially if you want the JDK tools as well. (There are a lot of them!)
If you use Chef, another approach is to use the "java" cookbook to do the installation.
Answered By - Stephen C Answer Checked By - Mary Flores (WPSolving Volunteer)