title: Is it possible to write a program in Java without main() using JDK 1.7 or higher?
body: <p>The following program will print <code>Hello world</code> when compiled with <code>JDK 1.6</code> or lower versions of <code>JDK</code>.</p>
  
  <pre>
      public class A
      {
        static
        {
          System.out.println("Hello world");
          System.exit(0);
        }
      }
  </pre>
  
  <p>But <code>JDK 1.7</code> or higher versions will generate a runtime error as follows when the above program is compiled.</p>
  
  <pre>
      Error: Main method not found in class A, please define the main method as:
         public static void main(String[] args)
      or a JavaFX application class must extend javafx.application.Application
  </pre>
  
  <p>I would like to know if there is some way to compile and run a program without <code>main()</code> successfully in Java using <code>JDK 1.7</code> or higher.</p>
  
  <p>Thanks in advance.</p>