Re: What's java equivalent of C's argv[ 0 ]?
Roedy Green wrote On 04/26/06 13:57,:
On Wed, 26 Apr 2006 10:07:08 -0400, Eric Sosman <Eric.Sosman@sun.com>
wrote, quoted or indirectly quoted someone who said :
(No, the existence of multiple main() methods is not
a mere perversity
Other uses of multiple main methods:
1. a test driver method on each class to help debug and test it in
isolation.
2. various canned setups that call the generic main so you don't need
an elaborate generated command line.
3. Use the same jar to do several different things. It is a utility
suite.
And the list goes on. My point is that the attempt to
identify "the program" by picking out the name of one of its
many classes is likely to fail. There really isn't such a
thing as "the program" in Java; there's just a collection of
classes the JVM happens to load, and that collection can vary
from one run to the next. There's no "there" there, not in
the same way there is for a statically-linked language.
There might be a way to learn the name of the class the
JVM was told to load when it first started up, but even that
could turn out to be uninformative. If you learned that "the
program" was com.tools.java.debuggers.CoverageAnalyzer, the
information might not be of a lot of use ...
--
Eric.Sosman@sun.com