title: Writing a simple application to inject messages onto a queue
body: <p>I'm trying to write a simple Java program to inject an MQ message onto a queue. I'm very inexperienced with writing to MQ queues using Java and have a couple of questions.</p>
  
  <ol>
  <li>Can I connect to the unix queue on the unix box from my windows machine? </li>
  <li>When I try to run the application I get a ....
  java.lang.UnsatisfiedLinkError: no mqjbnd05 in java.library.path</li>
  </ol>
  
  <p>From the sounds of what I could find in google I am missing some sort of resource. I'm thinking I'm getting this error possibly bc I'm not allowed to connect to the queue from windows?</p>
  
  <p>Any good examples of how to achieve what I'm doing or help would be appreciated.</p>
  
  <pre><code>public class MQInject {
  
      private MQQueueManager _queueManager = null;
      private Hashtable params = null;
  
      public int port = 1414;
      public static final String hostname    = "UQMYPOSIS1";
      public static final String channel     = "MQTX1012.MQTX1013";
      public static final String qManager    = "MQTX1013";
      public static final String outputQName = "IIS.TLOG.5";
  
      public MQInject(){
          super();
      }
  
      public void init(){
  
          //Set MQ connection credentials to MQ Envorinment.
           MQEnvironment.hostname = hostname;
           MQEnvironment.channel = channel;
           MQEnvironment.port = port;
           //MQEnvironment.userID = "";
           //QEnvironment.password = password;
           //set transport properties.
           MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
  
           try {
               //initialize MQ manager.
               _queueManager = new MQQueueManager(qManager);
          } catch (MQException e) {
              e.printStackTrace();
          }
      }    
  
      public static void main(String[] args)
      {
  
          MQInject write = new MQInject();
          try
          {
              write.selectQMgr();
              write.write();
          }
          catch (IllegalArgumentException e)
          {
              System.out.println("Usage: java MQWrite &lt;-h host&gt; &lt;-p port&gt; &lt;-c channel&gt; &lt;-m QueueManagerName&gt; &lt;-q QueueName&gt;");
              System.exit(1);
          }
          catch (MQException e)
          {
              System.out.println(e);
              System.exit(1);
          }
      }
  
      private void selectQMgr() throws MQException
      {
        _queueManager = new MQQueueManager(qManager);
      }    
  
  
      private void write() throws MQException{
       String line;
       int lineNum=0;
       int openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING;
  
       try {
           MQQueue queue = _queueManager.accessQueue( outputQName,
                   openOptions,
                   null,           // default q manager
                   null,           // no dynamic q name
                   null );         // no alternate user id
  
           DataInputStream input = new DataInputStream(System.in);
  
           System.out.println("MQWrite v1.0 connected");
           System.out.println("and ready for input, terminate with ^Z\n\n");
  
           // Define a simple MQ message, and write some text in UTF format..
           MQMessage sendmsg               = new MQMessage();
           sendmsg.format                  = MQC.MQFMT_STRING;
           sendmsg.feedback                = MQC.MQFB_NONE;
           sendmsg.messageType             = MQC.MQMT_DATAGRAM;
           sendmsg.replyToQueueName        = "ROGER.QUEUE";
           sendmsg.replyToQueueManagerName = qManager;
  
           MQPutMessageOptions pmo = new MQPutMessageOptions();  // accept the defaults, same
                                   // as MQPMO_DEFAULT constant
           while ((line = input.readLine()) != null){
               sendmsg.clearMessage();
               sendmsg.messageId     = MQC.MQMI_NONE;
               sendmsg.correlationId = MQC.MQCI_NONE;
               sendmsg.writeString(line);
               // put the message on the queue
               queue.put(sendmsg, pmo);
               System.out.println(++lineNum + ": " + line);
           }
  
           queue.close();
           _queueManager.disconnect();
  
          }catch (com.ibm.mq.MQException mqex){
              System.out.println(mqex);
          }
          catch (java.io.IOException ioex){
              System.out.println("An MQ IO error occurred : " + ioex);
          }
      }   
  }
  </code></pre>