19.2. Configure the Default JDK on Red Hat Enterprise Linux
Task Summary
It is possible to have multiple Java Development Kits (JDKs) installed on your Red Hat Enterprise Linux system. This task shows you how to specify which one your current environment uses. It uses the alternatives command.
This task only applies to Red Hat Enterprise Linux.
Note
It may not be necessary to do this step. Red Hat Enterprise Linux uses OpenJDK 1.6 as the default option. If this is what you want, and your system is working properly, you do not need to manually specify which JDK to use.
Task Prerequisites
In order to complete this task, you need to have superuser access, either through direct login or by means of the sudo command.
Determine the paths for your preferred
javaandjavacbinaries.You can use the commandrpm -ql packagename |grep binto find the locations of binaries installed from RPMs. The default locations of thejavaandjavacbinaries on Red Hat Enterprise Linux 32-bit systems are as follows.Table 19.1. Default locations for
javaandjavacbinariesJDK Path OpenJDK 1.6 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java/usr/lib/jvm/java-1.6.0-openjdk/bin/javacOracle JDK 1.6 /usr/lib/jvm/jre-1.6.0-sun/bin/java/usr/lib/jvm/java-1.6.0-sun/bin/javacSet the alternative you wish to use for each.
Run the following commands to set your system to use a specificjavaandjavac:/usr/sbin/alternatives --config javaor/usr/sbin/alternatives --config javac. Follow the on-screen instructions.Optional: Set the
java_sdk_1.6.0alternative choice.If you want to use Oracle JDK, you need to set the alternative forjava_sdk_1.6.0.as well. Use the following command:/usr/sbin/alternatives --config java_sdk_1.6.0. The correct path is usually/usr/lib/jvm/java-1.6.0-sun. You can do a file listing to verify it.
Result:
The alternative JDK is selected and active.