[IBM i]

Setting up IBM MQ on IBM i with Java and JMS

This collection of topics gives an overview of how you set up and test IBM® MQ with Java and JMS on IBM i using CL commands or the qshell environment.

Note:
  • From IBM MQ 8.0, ldap.jar, jndi.jar and jta.jar are part of the JDK.
  • [Jakarta Messaging 3.0]From IBM MQ 9.3.0, Jakarta Messaging 3.0 is supported for developing new applications. IBM MQ 9.3.0 and later continue to support JMS 2.0 for existing applications. It is not supported to use both the Jakarta Messaging 3.0 API and the JMS 2.0 API in the same application. For more information, see Using IBM MQ classes for JMS/Jakarta Messaging.

Using CL commands

The CLASSPATH that you set, is for testing with MQ base Java, JMS with JNDI, and JMS without JNDI.

If you do not use a .profile file under your /home/Userprofile directory, you will need to set the system level environment variables. You can check to see if they are set using the WRKENVVAR command.
  1. To view the environment variables for the entire system issue the command: WRKENVVAR LEVEL(*SYS)
  2. To view the environment variables specific to your job issue the command : WRKENVVAR LEVEL(*JOB)
  3. If the CLASSPATH is not set, issue the following command:
    [Jakarta Messaging 3.0]
    
    ADDENVVAR ENVVAR(CLASSPATH)
           VALUE('.:/QIBM/ProdData/mqm/java/lib/com.ibm.mq.jar
           :/QIBM/ProdData/mqm/java/lib/connector.jar:/QIBM/ProdData/mqm/java/lib
           :/QIBM/ProdData/mqm/java/samples/base
           :/QIBM/ProdData/mqm/java/lib/com.ibm.mq.jakarta.client.jar
           :/QIBM/ProdData/mqm/java/lib/jms.jar
           :/QIBM/ProdData/mqm/java/lib/providerutil.jar
           :/QIBM/ProdData/mqm/java/lib/fscontext.jar:') LEVEL(*SYS) 
    
    [JMS 2.0]
    
    ADDENVVAR ENVVAR(CLASSPATH)
           VALUE('.:/QIBM/ProdData/mqm/java/lib/com.ibm.mq.jar
           :/QIBM/ProdData/mqm/java/lib/connector.jar:/QIBM/ProdData/mqm/java/lib
           :/QIBM/ProdData/mqm/java/samples/base
           :/QIBM/ProdData/mqm/java/lib/com.ibm.mq.allclient.jar
           :/QIBM/ProdData/mqm/java/lib/jms.jar
           :/QIBM/ProdData/mqm/java/lib/providerutil.jar
           :/QIBM/ProdData/mqm/java/lib/fscontext.jar:') LEVEL(*SYS) 
    
  4. If QIBM_MULTI_THREADED is not set, issue the following command:
    ADDENVVAR ENVVAR(QIBM_MULTI_THREADED) VALUE('Y') LEVEL(*SYS)
    
  5. If QIBM_USE_DESCRIPTOR_STDIO is not set, issue the following command:
    ADDENVVAR ENVVAR(QIBM_USE_DESCRIPTOR_STDIO) VALUE('I') LEVEL(*SYS)
    
  6. If QSH_REDIRECTION_TEXTDATA is not set , issue the following command:
    ADDENVVAR ENVVAR(QSH_REDIRECTION_TEXTDATA) VALUE('Y') LEVEL(*SYS)
    

Using the qshell environment

If you use the QSHELL environment, you can set up a .profile in your /home/Userprofile directory. For more information reference the Qshell Interpreter (qsh) documentation.

Specify the following in the .profile. Note that the CLASSPATH statement must be on a single line, or separated onto different lines using the \ character as shown.

[Jakarta Messaging 3.0]

CLASSPATH=.:/QIBM/ProdData/mqm/java/lib/com.ibm.mq.jar: \
/QIBM/ProdData/mqm/java/lib/connector.jar: \
/QIBM/ProdData/mqm/java/lib: \
/QIBM/ProdData/mqm/java/samples/base: \
/QIBM/ProdData/mqm/java/lib/com.ibm.mq.jakarta.client.jar: \
/QIBM/ProdData/mqm/java/lib/jms.jar: \
/QIBM/ProdData/mqm/java/lib/providerutil.jar: \
/QIBM/ProdData/mqm/java/lib/fscontext.jar: 
HOME=/home/XXXXX
LOGNAME=XXXXX
PATH=/usr/bin:
QIBM_MULTI_THREADED=Y QIBM_USE_DESCRIPTOR_STDIO=I
QSH_REDIRECTION_TEXTDATA=Y
TERMINAL_TYPE=5250
[JMS 2.0]

CLASSPATH=.:/QIBM/ProdData/mqm/java/lib/com.ibm.mq.jar: \
/QIBM/ProdData/mqm/java/lib/connector.jar: \
/QIBM/ProdData/mqm/java/lib: \
/QIBM/ProdData/mqm/java/samples/base: \
/QIBM/ProdData/mqm/java/lib/com.ibm.mq.allclient.jar: \
/QIBM/ProdData/mqm/java/lib/jms.jar: \
/QIBM/ProdData/mqm/java/lib/providerutil.jar: \
/QIBM/ProdData/mqm/java/lib/fscontext.jar: 
HOME=/home/XXXXX
LOGNAME=XXXXX
PATH=/usr/bin:
QIBM_MULTI_THREADED=Y QIBM_USE_DESCRIPTOR_STDIO=I
QSH_REDIRECTION_TEXTDATA=Y
TERMINAL_TYPE=5250

Ensure that the QMQMJAVA library is in the library list by issuing the command DSPLIBL.

If the QMQMJAVA library is not in the list, add it using the following command: ADDLIBLE LIB(QMQMJAVA)