File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invoking the main() from another class

 
David Duran
Ranch Hand
Posts: 122
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a cleaner way to invoke the main method of a class from within another class other than below?
String[] fakeCommandLineArgs = {};
MyClass.main(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
whippersnapper
Ranch Hand
Posts: 1796
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MyClass.main( null ) ;
 
Adam Blinkinsop
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'nuff said.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic