SUSE Support

Here When You Need Us

Various methods to set which JRE is used in SUSE Linux

This document (3578376) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 10
SUSE Linux Enterprise Desktop 10

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/<nxxxll>/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.

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:3578376
  • Creation Date: 27-Feb-2007
  • Modified Date:15-Mar-2021
    • SUSE Linux Enterprise Desktop
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.