In Java 6 the class runs in the following sequence:
1) There is a loading class MainClass;
2) The initialization of the class and the blocks with static initialization are being made;
3) And then the JVM might try to call the method main(), that is absent in the class MainClass. But in the static block the completion of the program by calling System.exit (0). has already happened
In Java 7 the sequence is changed a bit the resolving of the main method is executed to the class initialization. Therefore, immediately ejected NoSuchMethodException, handler displays a message
Error: Main method not found in class MainClass, please define the main method as:
public static void main (String[] args)
Войдите чтобы поставить Нравится
Войдите чтобы прокомментировать