Sun Java System Message Queue 4.3 Administration Guide

ProcedureTo Run the Sample Application

  1. Make the directory containing the HelloWorldmessageJNDI application your current directory, using one of the following commands (depending on the platform you’re using):

    • On Solaris:

         cd /usr/demo/imq/helloworld/helloworldmessagejndi
    • On Linux:

         cd /opt/sun/mq/examples/helloworld/helloworldmessagejndi
    • On Windows:

         cd IMQ_HOME\\demo\\helloworld\\helloworldmessagejndi

    You should find the file HelloWorldMessageJNDI.class present. (If you make changes to the application, you must recompile it using the procedure for compiling a client application given in the Message Queue Developer’s Guide for Java Clients.)

  2. Set the CLASSPATH variable to include the current directory containing the file HelloWorldMessageJNDI.class, as well as the following .jar files that are included in the Message Queue product:





    See the Message Queue Developer’s Guide for Java Clients for information on setting the CLASSPATH variable.

    Note –

    The file jndi.jar is bundled with JDK 1.4. You need not add this file to your CLASSPATH unless you are using an earlier version of the JDK.

  3. Run the HelloWorldMessageJNDI application by executing one of the following commands (depending on the platform you’re using):

    • On Solaris or Linux:

         % java HelloWorldMessageJNDI file:///tmp
    • On Windows:

         java HelloWorldMessageJNDI

    If the application runs successfully, you should see the output shown in Example 2–1.

Example 2–1 Output from Sample Application

java HelloWorldMessageJNDI
Using file:///C:/Temp for Context.PROVIDER_URL

Looking up Queue Connection Factory object with lookup name:
Queue Connection Factory object found.
Looking up Queue object with lookup name: MyQueue
Queue object found.

Creating connection to broker.
Connection to broker created.

Publishing a message to Queue: MyQueueDest
Received the following message: Hello World