Configure 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 starting
See Configure 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, we must configure the environment's library path so that the Java virtual machine (JVM) can load the mqjbnd library before you start the IBM MQ classes for JMS application.
IBM MQ provides two Java Native Interface (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 Version 9.0 can be used to connect to any IBM MQ Version 9.0 (or earlier) queue manager.
- mqjexitstub02
- The mqjexitstub02 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.
On certain platforms, IBM MQ installs 32-bit and 64-bit versions of these JNI libraries. The location of the libraries for each platform is shown in Table 1.
Platform Directory containing the IBM MQ classes for JMS libraries AIX
Linux
(POWER, x86-64 and zSeries s390x platforms)
MQ_INSTALLATION_PATH/java/lib (32-bit libraries)
MQ_INSTALLATION_PATH/java/lib64 (64-bit libraries)
Windows MQ_INSTALLATION_PATH\java\lib (32-bit libraries)
MQ_INSTALLATION_PATH\java\lib64 (64-bit libraries)
z/OS MQ_INSTALLATION_PATH/mqm/V9R1M0/java/lib
(31-bit and 64-bit libraries)
MQ_INSTALLATION_PATH represents the high-level directory in which IBM MQ is installed.
Note: On z/OS, we 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
- 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_directoryFor example, for a 64-bit 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 64-bit JVM and a default IBM MQ installation location, we can use the following settings:
export LIBPATH=/usr/mqm/java/lib64:$LIBPATHexport LD_LIBRARY_PATH=/opt/mqm/java/lib64:$LD_LIBRARY_PATHset 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 WebSphere 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- After either the 32-bit or 64-bit environment has been set up, start the IBM MQ classes for JMS application using the command:
java application-namewhere 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:
- The IBM MQ classes for JMS application is run in a 32-bit Java runtime environment, and a 64-bit environment has been set up for the IBM MQ classes for JMS, as the 32-bit Java runtime environment is unable to load the 64-bit Java Native Library.
- The IBM MQ classes for JMS application is run in a 64-bit Java runtime environment, and a 32-bit environment has been set up for the IBM MQ classes for JMS, as the 64-bit Java runtime environment is unable to load the 32-bit Java Native Library.
Parent topic: What is installed for IBM MQ classes for JMS