The first thing i want to say is code which is present in a static block will be executed as the class is initialised.the code given by you is in static block it will definately run when class gets initialised,even if you do not give main method...........
Originally posted by Kaydell Leavitt: There has to be a main method somewhere doesn't there or there could be no entry point.
When you run the command java Mainless the JVM will load the Mainless class, run any static blocks and then try to call the main method. However, in this case there is a System.exit() in the static block so the program will exit before it tries to call main. If you take out the System.exit(), you will get an error.
Apart from rather silly hacks like the static initialiser one, a Java program must have a main() method, if it is to be run via the "java" command.
However, the "java" command is not the only way to run Java. Applets start a different way, for one thing. But also you can write your own replacement for the "java" command using JNI. This can load any class it likes and can call any methods it likes.
Writing a replacement for "java" isn't a beginner topic, though!
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P