title: Java Main Method, Good Coding Style
body: <p>I've had quite a long discussion with a friend of mine about the correct and good use of the main method in Java. Basically we have a class like this:</p>
  
  <pre><code>public class AnImporter implements Runnable {
    // some methods, attributes, etc.
  }
  </code></pre>
  
  <p>But where to put the main method? I concider it a good practice to "keep code where it belongs", thus turning the above code into</p>
  
  <pre><code>public class AnImporter implements Runnable {
    public static void main(String [] args){
      // Startup code for Importer App here
    }
    // some methods, attributes, etc.
  }
  </code></pre>
  
  <p>While my buddy argues that "the startup code has nothing to do with the application itself", thus it should be placed in another class, like this:</p>
  
  <pre><code>public class AnImporter implements Runnable {
    // some methods, attributes, etc.
  }
  
  public class AnApplication {
    // Nothing here
    public static void main(String [] args){
      AnImporter a = new AnImporter();
      // Startup code here
    }
    // Nothing here
  }
  </code></pre>
  
  <p>Despite the fact that we discussed the matter for some time we both ended up with no conclusion on which way is the better approach in Java. What's your oppinion on this topic? Where and most importantly, why, do you place your main method where you placed it?</p>