title: Hello world works but then gets error that there's no main?
body: <p>I have the following simple hello world in Java:</p>
  
  <pre><code>class A {
      static {
          System.out.println("Hello world");
      }
  }
  </code></pre>
  
  <p>It works as expected, but oddly, it gives an error saying that the main method doesn't exist after.</p>
  
  <pre><code>$ javac A.java &amp;&amp; java A
  Hello world
  Exception in thread "main" java.lang.NoSuchMethodError: main
  </code></pre>
  
  <p>Why? Should I ignore it? I even tried making a method called "main", but it changes nothing.</p>
  
  <pre><code>class A {
      static {
          main();
      }
      public static void main() {
          System.out.println("Hello world");
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>$ javac A.java &amp;&amp; java A
  Hello world
  Exception in thread "main" java.lang.NoSuchMethodError: main
  </code></pre>