I have written a simple class with one static block
class Hello
{
static {
System.out.println(\"Hello\");
System.exit(0);
}
}
before java 1.7 static block is execute before the main method so we can execute code without main mehod, Since JDK 1.7, it is not possible to execute static bock without the main method,because compiler is looking for main method in class file.
so when we want to execute code in above JDK 1.7 it show Error: Main method not found in class hello, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application