This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes calling of main() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "calling of main()" Watch "calling of main()" New topic
Author

calling of main()

pinto rajput
Greenhorn

Joined: Apr 06, 2005
Posts: 3
sir,
i want to know that can a main method of a class be invoked in another class,if yes how .explain me with an example.
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
You can do it. I don't know why you need someone to provide an example.
Why can't you write 2 classes and try calling the main method of one class from the main method of another class?


Mani
Quaerendo Invenietis
Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
The only thing special about main is that it's the one that gets run if you say 'java SomeClass' on the command line. Of course it only works if the signature is just perfect (static, with string array for parm, you know). I wouldn't call it, though. I'd do something like this if I had the need:

 
Don't get me started about those stupid light bulbs.
 
subject: calling of main()
 
Similar Threads
How to use jexegen
Class not found error
manifest file
How to call a stand alone class from WAS???
different command-line startup on linux (vs. windows) not working