Here this example will explain how to run a program with no main method in Java.
Source Code
ppackage com.beginner.examples;
public class NomainExample{
static
{
System.out.println("Done!");
System.exit(0);
}
}
Output:
Done!