Configuring the Java Native Interface (JNI) libraries

IBM® MQ classes for JMS applications, that either connect to a queue manager using the bindings transport, or that connect to a queue manager using the client transport and use channel exit programs written in languages other than Java, need to be run in an environment that allows access to the Java Native Interface (JNI) libraries.

Before you begin

See Configuring the IBM MQ messaging provider with native libraries information for more information on using the WebSphere® Application Server environment.

About this task

To set up this environment, you must configure the environment's library path so that the Java Virtual Machine (JVM) can load the JNI libraries before you start the IBM MQ classes for JMS application.

IBM MQ provides two Java JNI libraries:
mqjbnd
This library is used by applications that connect to a queue manager using the bindings transport. It provides the interface between the IBM MQ classes for JMS and the queue manager. The mqjbnd library installed with IBM MQ 10.0 can be used to connect to any IBM MQ 10.0 (or earlier) queue manager.
mqjexitstub02
This library is loaded by the IBM MQ classes for JMS when an application connects to a queue manager using the client transport and uses a channel exit program written in a language other than Java.

The location of the libraries for each platform is shown in Table 1.

Table 1. The location of the IBM MQ classes for JMS libraries for each platform
Platform Directory containing the JNI libraries
[AIX]AIX®
[Linux]Linux® (POWER, x86-64 and s390x platforms)

MQ_INSTALLATION_PATH/java/lib64
[Windows]Windows

MQ_INSTALLATION_PATH\java\lib64
[z/OS]z/OS®
MQ_INSTALLATION_PATH/java/lib
(31-bit and 64-bit libraries)

MQ_INSTALLATION_PATH represents the high-level directory in which IBM MQ is installed.

[z/OS]Note: On z/OS, you can use either a 31-bit or 64-bit Java Virtual Machine (JVM). You do not have to specify which JNI libraries to use; IBM MQ classes for JMS can determine for itself which JNI libraries to load.

Procedure

  1. Configure the JVM's java.library.path property, which can be done in two ways:
    • By specifying the JVM argument as shown in the following example:
      -Djava.library.path=path_to_library_directory
      [Linux]For example, for a JVM on Linux for a default location installation, specify:
      -Djava.library.path=/opt/mqm/java/lib64
    • By configuring the shell's environment such that the JVM will set up its own java.library.path. This path varies by platform and by the location in which you installed IBM MQ. For example, for a default IBM MQ installation location, you can use the following settings:
      [AIX]
      export LIBPATH=/usr/mqm/java/lib64:$LIBPATH
      [Linux]
      export LD_LIBRARY_PATH=/opt/mqm/java/lib64:$LD_LIBRARY_PATH
      [Windows]
      set PATH=C:\Program Files\IBM\MQ\java\lib64;%PATH%
    An example of the exception stack that you see when the environment has not been configured correctly is as follows:
    Caused by: com.ibm.mq.jmqi.local.LocalMQ$4: CC=2;RC=2495;
    AMQ8598: Failed to load the IBM MQ native JNI library: 'mqjbnd'.
        at com.ibm.mq.jmqi.local.LocalMQ.loadLib(LocalMQ.java:1268)
        at com.ibm.mq.jmqi.local.LocalMQ$1.run(LocalMQ.java:309)
        at java.security.AccessController.doPrivileged(AccessController.java:400)
        at com.ibm.mq.jmqi.local.LocalMQ.initialise_inner(LocalMQ.java:259)
        at com.ibm.mq.jmqi.local.LocalMQ.initialise(LocalMQ.java:221)
        at com.ibm.mq.jmqi.local.LocalMQ.<init>(LocalMQ.java:1350)
        at com.ibm.mq.jmqi.local.LocalServer.<init>(LocalServer.java:230)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:86)       
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:58)       
        at java.lang.reflect.Constructor.newInstance(Constructor.java:542)
        at com.ibm.mq.jmqi.JmqiEnvironment.getInstance(JmqiEnvironment.java:706)
        at com.ibm.mq.jmqi.JmqiEnvironment.getMQI(JmqiEnvironment.java:640)
        at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:8437)       
        ... 7 more
    Caused by: java.lang.UnsatisfiedLinkError: mqjbnd (Not found in java.library.path)
        at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1235)
        at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1205)
        at java.lang.System.loadLibrary(System.java:534)
        at com.ibm.mq.jmqi.local.LocalMQ.loadLib(LocalMQ.java:1240)
        ... 20 more
  2. After you set up the environment, start the IBM MQ classes for JMS application by using the following command:
    java application-name
    where application-name is the name of the IBM MQ classes for JMS application to be run.

    An exception containing IBM MQ Reason code 2495 (MQRC_MODULE_NOT_FOUND) is thrown by the IBM MQ classes for JMS if you run the IBM MQ classes for JMS application in a 32-bit Java runtime environment, because the 32-bit environment is not supported and the required JNI library is not available.