J2EE Messaging 891   /**    * Receives messages until sender sends a 'q' or 'Q'    */   public static void main(String[] args) throws Exception   {     // Create a Receiver.     Receiver receiver = new Receiver();     System.out.println("Receiver waiting for messages(Send 'q' OR 'Q' to quit).");     synchronized(receiver)     {       // Wait until the onMessage method changes the value of quit       while (!receiver.quit)       {         try         {           // Wait until notified           receiver.wait();         }         catch (InterruptedException ie)         {}       }     }     // Close up the JMS connections     receiver.close();   } } Running the PTP Examples If you already set up your server and environment to run the Pub/Sub examples, all you have to do to run the PTP examples is compile the two files Sender.java and Receiver.java. Then, configure MyJMSQueue like you configured MyJMSTopic. Once you set up the queue and compile the code, you can run the two programs at once. Messages you type in the Sender window will be sent to MyJMSQueue and you will see them show up as received messages in the Receiver window: You can also try making multiple Receiver windows. Only one Receiver on MyJMSQueue will receive any given message the Sender sends. Type in q or Q to exit both the Sender and any active Receivers.