This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Invoking the main() from another class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Invoking the main() from another class" Watch "Invoking the main() from another class" New topic

Invoking the main() from another class

David Duran
Ranch Hand

Joined: Feb 11, 2002
Posts: 122
Is there a cleaner way to invoke the main method of a class from within another class other than below?
String[] fakeCommandLineArgs = {};
I don't intend on passing arguments to the main so I'd like to avoid creating an empty String array if possible.
Michael Matola
Ranch Hand

Joined: Mar 25, 2001
Posts: 1783
MyClass.main( null ) ;
Adam Blinkinsop

Joined: Mar 22, 2002
Posts: 7
'nuff said.
I agree. Here's the link:
subject: Invoking the main() from another class
It's not a secret anymore!