/usr/sbin/alternatives Utility /usr/sbin/alternatives is a tool for managing different software packages that provide the same functionality. Red Hat Enterprise Linux uses /usr/sbin/alternatives to ensure that only one Java Development Kit is set as the system default at one time.
/usr/sbin/alternatives may contain conflicting configurations. Refer to Procedure C.4, “ Using /usr/sbin/alternatives to Set the Default JDK ” for syntax of the /usr/sbin/alternatives command.
/usr/sbin/alternatives to Set the Default JDK Become the root user.
/usr/sbin/alternatives needs to be run with root privileges. Use the su command or other mechanism to gain these privileges.
Set java.
/usr/sbin/alternatives --config java
java is selected. Table C.1, “java alternative commands” shows the relevant command settings for each of the different JDKs.
java alternative commands| JDK | alternative command |
|---|---|
| OpenJDK 1.6 |
/usr/lib/jvm/jre-1.6.0-openjdk/bin/java
|
| Sun Microsystems JDK 1.6 |
/usr/lib/jvm/jre-1.6.0-sun/bin/java
|
Set javac.
/usr/sbin/alternatives --config javac
javac is selected. Table C.2, “javac alternative commands” shows the appropriate command settings for the different JDKs.
javac alternative commands| JDK | alternative command |
|---|---|
| OpenJDK 1.6 |
/usr/lib/jvm/java-1.6.0-openjdk/bin/javac
|
| Sun Microsystems JDK 1.6 |
/usr/lib/jvm/java-1.6.0-sun/bin/javac
|
Extra Step: Set java_sdk_1.6.0.
/usr/sbin/alternatives --config java_sdk_1.6.0
java_sdk is selected. It is /usr/lib/jvm/java-1.6.0-sun.