title: How do I verify that a JMS queue exists using Java?
body: <p>How can I check whether a queue exists on a JMS server using the Java API? I don't want to send or receive any data to the queue for now, just verify that the queue exists. Also, the queue may be empty.</p>
  
  <p>Here is my code sample. I have removed the error handling for simplicity.</p>
  
  <pre><code>    Connection connection = null;
      Session session = null;
      connection = factory.createConnection();
      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  
      //I was hoping this next line would throw an exception if the queue does not exist
      Queue queue = session.createQueue(queueName);
  </code></pre>
  
  <p>My JMS server is TIBCO EMS. I'm hoping for a solution that works on versions 5-7.</p>
  
  <p><strong>Solution</strong></p>
  
  <p>I followed the recommendation in the accepted answer but created a browser instead. The following line threw an exception as desired:</p>
  
  <pre><code>QueueBrowser browser = session.createBrowser(queue);
  </code></pre>