The uncaught exception handler, presumably. Which just does a printStackTrace() and then the thread terminates. Same as happens now for any uncaught RuntimeException or Error.
Leonardo: how would throws Exception be a default? That is, if you wanted to override this default so that main() didn't throw Exception, how would you represent it? Normally we achieve this by not writing "throws Exception". But if that were taken to mean something else, what do we write in its place? "throws no Exception?
Also, what's special about main()? Why not apply this idea to all methods? In which case, why have checked exceptions at all? In fact, there are a number of people who prefer not using checked exceptions, and avoid them where possible. See here for a nice overview of the issues, and some more recent thoughts from the same author here. I think there's something to be said for the idea of getting rid of checked exceptions entirely. But I don't see any reason to give the main() method special treatment here. If we want to remove the problems with checked exceptions, better to remove them from all methods, I think. Or not at all. We don't need a special rule just for main().
Regardless, I think it's very unlikely anything in the Java language will change here. These thoughts may influence future languages. And they've certainly influenced some libraries and frameworks. E.g. Spring uses unchecked exceptions extensively in places most conventional Java programmers would use checked exceptions.
Main has unchecked exceptions by default. All these exceptions will be handled by VM and generally will issue its termination. Main has no any differences from any other static public method. It's matter of VM wrapper of calling main(). You can wrtite another VM wrapper which will cal myname() as entry point.
Perhaps another reason main dosnt default to throws Exception, is that it is considered good practise for your application to "exit gracefully" if anything goes wrong, and if main throws the exception, your program has hardly exited gracefully.
However what I do think is "wrong" is that an exception should be an event that is exceptional in the flow of the program, and that in general checked exceptions are over used, and that somethings that are acceptions should perhaps be runtime (or otherwise) errors.
Having worked with C# fairly recently (version2/2005) I find that it has an "unchecked" approach to exceptions, and in my opionon and experience I would rather have the checked exception approach of Java, even if i feel it is often over used.
Sorry just my 2pence and probably way off topic. :S
The formal reason is that, from the language's point of view, there isn't anything special about the main method. It's only the standard JVM that handles it specifically (by using it as the entry point for an application) - the compiler doesn't know anything about this. And other VMs use different entry points - for example for applets.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss: The formal reason is that, from the language's point of view, there isn't anything special about the main method. It's only the standard JVM that handles it specifically
The special meaning of main() is not built into the JVM. It is built into the "java[.exe]" program.
You can write a replacement for "java[.exe]" which uses the same JVM, but runs the code using different method(s). Doing so is part of JNI.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
subject: why main() does not throws Exception by default?