title: What should the Java main method be for a standalone application (for Spring JMS)?
body: <p>I am interested in creating a Spring standalone application that will run and wait to receive messages from an ActiveMQ queue using Spring JMS. I have searched a lot of places and cannot find a consistent way of implementing the main method for such a standalone application. There appears to be few examples of Spring standalone applications. I have looked at Tomcat, JBoss, ActiveMQ and other examples from the around the web but I have not come to a conclusion so ...</p>
  
  <p>What is the best practice for implementing a main method for a Java application (specifically Spring with JMS) ?</p>
  
  <p><strong>Update</strong>:
  Here's an example from: <a href="http://forum.springsource.org/showthread.php?t=48197" rel="noreferrer">http://forum.springsource.org/showthread.php?t=48197</a>
  Is this the best way of doing this?</p>
  
  <pre><code>public static void main(String args[]) {
          try {
             ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
              . . . . .
              Object lock = new Object();
              synchronized (lock) {
                  lock.wait();  
              }
  
          } catch (Exception e) {
              e.printStackTrace();
          }
  }
  </code></pre>