Java application usually required a main() method as entry point to run it. Here’s an example by using static initializer to run a Java application even without the main() method.

P.S The static initializer is called while the Java class is loaded.
This is for fun only, do not use this example in real environment as a replacement for main() method, static initializer is not created for the Java main() application entry point purpose :)
package com.mkyong.io;
 
public class App{
 
     static
    {
        System.out.println("Magic here ~");
        System.exit(0);
 
    }
}
Run the above Java application, it will print out the “Magic here ~” to console.