Various methods to set which JRE is used in SUSE Linux

  • 3578376
  • 27-Feb-2007
  • 30-Apr-2012

Environment


Novell Open Enterprise Server (Linux based)
or
Novell SUSE Linux

Situation

This document describes a couple of methods that may be used to alter which JRE (Java Runtime Environment) is used by default.

Resolution

Method 1 - using the update-alternatives command

The update-alternatives command (also "alternatives" on some SUSE Linux platforms) can be used to modify the /etc/alternatives/ symbolic links to point to different binaries. For example :
update-alternatives --config java
update-alternatives --config javac
Method 2 - altering the /etc/java/java2.conf file

With SUSE many applications are compiled to check the /etc/java/java2.conf file (or other files in the /etc/java directory if java2.conf doesn't exist). If no java2.conf file exists, copy one from an existing file in the same directory to java2.conf, and modify it accordingly. It will need all of the directories set appropriately (e.g."JRE_HOME=/opt/novell/j2sdk-1.4.2_05/jre").

Method 3 - the unsupported hack of symlinks

In the /usr/lib directory, there should be a 'java' symbolic link. Rename this using :

mv /usr/lib/java /usr/lib/java.old

Then, create a new symbolic link to the new java directory's JDK. For example, if the new Java Development Kit is stored in /usr/lib/SunJava-1.4.2, the command would appear as :

ln -s /usr/lib/SunJava-1.4.2 /usr/lib/java

It may be wise to restart any java applications to ensure that they are still compatible with the intended Java environment and that the switch was made successfully.

Additional Information

Not all methods will work on all servers - primarily due to the wide range of java implementations that exist. Additionally, this is not the complete list of methods to switch Java environments. Test one method at a time to see if it performs as expected. A good method to test which java environment is to be used is to install the apache-ant package, and run "ant -diagnose". This will print all of the variables, including a "java.home" - which should point to the directory of the JRE/JDK directory.

Feedback service temporarily unavailable. For content questions or problems, please contact Support.