ICS/Lotus (mostly), Linux, Travel, Skiing, Mixology, and Random Musing of Interest

LMC Corner -- Ensuring You Are Using The Right Java Build

Bill Malchisky  October 5 2012 02:00:00 AM
To determine if IBM Java is installed on our machine, type:
#rpm -qa |grep IBM

Then, find the subdirectory for the java executable $ls /opt/
You'll see IBMJava2.... (the rest is version specific e.g.: IBMJava2-1.4.2)
$ls /opt/IBM [tab][tab] ; [tab]jre/[tab][tab]bin/java

Record this path for use below.

A.  You are probably wondering why I prefaced the "ls /opt" command with the RPM sequence? Simply put, just because a product exists on one's server, does not necessarily indicate that it is installed and therefore recognized properly by the system.
B. The [tab][tab] sequence denotes file completion assistance to save you time, the characters on the command line do not change with this feature
C. Although it is installed by default, you do not have the IBM JVM installed, then you need to install it first to have the LMC software work properly; see the installation files for the package

Yes, upon installing the IBM JRE, you need to do a verification test to ensure that everything is working properly.
1. #java -version
If you see
"gij (GNU libgcj) ..."
"gcj ... "

these are the default installed Java versions with Red Hat. Thus, they are (a) potentially older; (b) not the installed IBM version that the LMC is compiled against during the build.

2. If you see
Java(TM) 2 Runtime Environment, Standard Edition (Build 1.4.2)
Classic VM (build 2.4.2), J2RE 1.4.2 IBM build cxia...

Then you have the correct working Java version for the LMC.

To fix issues with (1) above, there are two ways to resolve the matter

1. Redirecting the executable
#which java

Verify where the Java executable is pointing:
#ls -l /usr/bin/java
/usr/bin/java -> /etc/alternatives/java

If it is not pointing to IBM (it won't be if you are here, unless you have a heavily customized Red Hat box);
#rm /usr/bin/java (or mv if you prefer)
Syntax: #ln -s
Example: #ln -s /opt/IBMJava2-142/jre/bin/java /usr/bin/java
#ls -l /usr/bin/java

Verify that you see: /usr/bin/java -> /opt/IBMJava2-142/jre/bin/java
#which java
#java -version

If you see IBM listed now, you are all set

2. Altering the path - a bit more complex, so unless you are comfortable editing a text file, just do the first one
$ls /opt/IBMJava2-142/jre/bin/java
(see if it exists; change for the version if it is no 1.4.2
#vi /etc/profile
proceed till you find the last entry and append the path to the IBM Java path (from the the "To determine if IBM Java is installed..." section
Save your file and run the #java -version command again to ensure success.

Note: solution one is the preferred approach and should be used, unless you have a need to run multiple JVMs in production, which is why the alternate solution is provided; though one should be mindful of the scope issue with the path, as the first match that the IBM Java request finds is the one that will execute.

1Stephan H. Wissel  10/5/12 10:06:46 PM  LMC Corner -- Ensuring You Are Using The Right Java Build

In the Ubuntu world you would type:

sudo update-alternatives --config java

It lists all known Java installations and you can pick which one is active. Is there a similar command in the Redhat/Suse (or whatever rpm based distro you use)?

2Bill Malchisky  3/27/13 7:34:34 AM  LMC Corner -- Ensuring You Are Using The Right Java Build

Hi Stephen... yes, there is an equivalent command and you are correct that Linux along with UNIX has the capability to allow administrators several different ways to do things. I wanted to keep the article at a level for the audience here who is trying out Linux with a new product and thus keep things easy for them. The issue with the command for beginners or people who use it less than they realize is that there are three separate places where they would need to be exercise the config Java command. If they don't come back to the box for an extended period of time, most likely they will forget that additional commands and cause consistency errors across Java versions -- perhaps even get turned off to Linux as a result (due to it being too complex, which it's not). Senior admins would have no issue with running the option and have no problem recommending it if asked.

Hope this helps. Thanks for the comment and great meeting you at IBM Connect in January.

Powered by IBM Lotus Domino 8 | Lotus User Group | Get Firefox! | This blog is listed on Planet Lotus   IBM Certified

© 2010 William Malchisky.