Use the IBM MQ classes for Java sample applications
The IBM MQ classes for Java sample applications provide an overview of the common features of IBM MQ classes for Java API. We can use them to verify your installation and messaging server set up and to help you build your own applications.
For help to create your own applications, we can use the sample applications as a starting point. Both the source and a compiled version are provided for each application. Review the sample source code and identify the key steps to create each required object for the application (MQQueueManager, MQConstants, MQMessage, MQPutMessageOptions and MQDestination), and to set any specific properties that are needed to specify how we want the application to work. For more information, see Writing IBM MQ classes for Java applications. The samples might be subject to change in future releases of IBM MQ Java.
Table 1 shows where the IBM MQ classes for Java sample applications are installed on each platform:Platform | Directory |
---|---|
UNIX Linux |
MQ_INSTALLATION_PATH/samp/wmqjava/samples |
Windows | MQ_INSTALLATION_PATH\tools\wmqjava\samples |
IBM i | /qibm/proddata/mqm/java/samples/wmqjava/samples |
z/OS | MQ_INSTALLATION_PATH/java/samples/wmqjava |
Name of sample | Description |
---|---|
IMSBridgeSample.java | Simple program to demonstrate using the IMS Bridge with the IBM MQ classes for Java. |
MQIVP.java | IBM MQ Java installation verification program. |
MQMessagePropertiesSample.java | Demonstrates the use of the Message Properties API introduced into IBM WebSphere MQ Version 7.0. |
MQPubSubApiSample.java | Demonstrates using the publish/subscribe API introduced into IBM WebSphere MQ Version 7.0. |
MQSample.java | Simple program to demonstrate putting and getting a message from a queue. |
MQSampleMessageManager.java | Utility class for message handling in the IBM MQ base Java samples. |
mqjcivp.properties | This resource bundle contains the messages used by the IBM MQ classes for Java installation verification program (MQIVP.java). |
The IBM MQ classes for Java provide a script called runjms that can be used to run the sample applications. This script sets up the IBM MQ environment to allow you to run the IBM MQ classes for Java sample applications.
Table 3 shows the location of the script on each platform:Platform | Directory |
---|---|
UNIX Linux |
MQ_INSTALLATION_PATH/java/bin/runjms |
Windows | MQ_INSTALLATION_PATH\java\bin\runjms.bat |
IBM i |
/qibm/proddata/mqm/java/bin/runjms or /qibm/proddata/mqm/java/bin/runjms64 |
z/OS | MQ_INSTALLATION_PATHjava/bin/runjms |
To use the runjms script to invoke a sample application, complete the following steps:
Procedure
- Bring up a command prompt and navigate to the directory containing the sample application that we want to run.
- Enter the following command:
Path to the runjms script/runjms sample_application_name
The sample application displays a list of parameters that it needs. - Enter the following command to run the sample with these parameters:
Path to the runjms script/runjms sample_application_name parameters
Example
For example, to run the MQIVP sample on Linux, enter the following commands:cd /opt/mqm/samp/wmqjava/samples /opt/mqm/java/bin/runjms MQIVPParent topic: Installing and configuring IBM MQ classes for Java
Related concepts