Setting up the Linux Java environment

Before implementing these instructions, do the setup in Setting up the UNIX Java environment.

Procedure

To build Java applications on Linux with DB2 JDBC support, you need to install and configure on your development machine:

  1. One of the following:

To run Java stored procedures or user-defined functions, the Linux run-time linker must be able to access certain Java shared libraries, and DB2 must be able to load both these libraries and the Java virtual machine. Since the program that does this loading runs with setuid privileges, it will only look for the dependent libraries in /usr/lib.

Create symbolic links in /usr/lib to point to the Java shared libraries. The number of required shared libraries that you will need to link to depends on the version of the IBM Developer Kit that you are using.

IBM Developer Kit 1.3

You require symbolic links to libjava.so, libjvm.so, and libhpi.so. You can create the symbolic links by running the following commands as root:

   cd /usr/lib
   ln -fs JAVAHOME/jre/bin/libjava.so .
   ln -fs JAVAHOME/jre/bin/classic/libjvm.so .
   ln -fs JAVAHOME/jre/bin/libhpi.so .

where JAVAHOME is the base directory for the IBM Developer Kit.

|IBM Developer Kit 1.4.1

|You require symbolic links to libjava.so, |libjvm.so, libhpi.so, and |libjsig.so. You can create the symbolic links by |running the following commands as root:

|   cd /usr/lib
|   ln -fs JAVAHOME/jre/bin/libjava.so .
|   ln -fs JAVAHOME/jre/bin/classic/libjvm.so .
|   ln -fs JAVAHOME/jre/bin/libhpi.so .
|   ln -fs JAVAHOME/jre/bin/libjsig.so .

|where JAVAHOME is the base directory for the IBM Developer |Kit.

|IBM Developer Kit 1.4.2

|You require symbolic links to libjava.so, |libjvm.so, libhpi.so, |libjsig.so, libjitc.so, |libxhpi.so, and libdbgmalloc.so. |You can create the symbolic links by running the following commands as |root:

|   cd /usr/lib
|   ln -fs JAVAHOME/jre/bin/libjava.so .
|   ln -fs JAVAHOME/jre/bin/classic/libjvm.so .
|   ln -fs JAVAHOME/jre/bin/libhpi.so .
|   ln -fs JAVAHOME/jre/bin/libjsig.so .
|   ln -fs JAVAHOME/jre/bin/libjitc.so .
|   ln -fs JAVAHOME/jre/bin/libxhpi.so .
|   ln -fs JAVAHOME/jre/bin/libdbgmalloc.so .
|   ldconfig

|where JAVAHOME is the base directory for the IBM Developer |Kit.

If DB2 cannot find these libraries, you will get a -4301 error when trying to run a Java routine, and there will be messages in the administration notification log about libraries not found.

Note:
An alternative to creating links in /usr/lib is to add the Java shared libraries to /etc/ld.so.conf. This alternative method can still not work in specific instances, also resulting in the routine hanging (not completing). If you encounter this, please create the links in the /usr/lib directory as instructed above. |After creating the symbolic links in /usr/lib or |modifying the file /etc/ld.so.conf, you must run |ldconfig as root to rebuild all the symbolic links to libraries and |build the cache. You must also restart DB2. If you are on a |64-bit platform and running a 64-bit JDK, you must create the symbolic links |in /usr/lib64 instead of /usr/lib.