"Matt Rose" <email@example.com> wrote in message
(Aside.) Whether the convention of having a method with a magic
signature as the entry point into all standalone java programs is
better than some more explicit approach like an Interface might be
worth wondering about. It made the original sales case for java closer
to C I suppose. I expect other people can come up with better
arguments either way.
From my perspective, it's not that method which has a magic signature:
the evidence is that you can have multiple class each with their own
"public void static main(String)" methods, and none of them are any more
magical than any other. Rather, it's the behaviour of the JVM itself which
is "magical". It can somehow manage the transfer of control from the
command line (or other external environment) into the JVM.
It just so happens that the "java.exe" command happens to take a class
as a command line argument, and tries to invoke the static main(String)
method of that class. But this is not conceptually different from a
browser creating an instance of a JApplet, and invoking its init(),
start() and stop() and destroy() methods. Doesn't mean that the JApplet is
magical. It just means that there's some sort of transfer of control from
your program to the outside environment.
I believe there are even IDEs for which you can specify the entry point
to be something other than a method called "main" (e.g. a static method
called "foo(String)" instead), which further reinforces that the magic
lies not in the method, but somewhere at a higher level than that.
There is nothing "magical" about it at all. It is called a "standard
must accept even if they don't agree).