File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Calling main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calling main method" Watch "Calling main method" New topic

Calling main method

jamie ong

Joined: Nov 05, 2001
Posts: 24
how can i start a class from another class?
which means, i want my first class to trigger the main method inside my second class.
Any advice will be appreciated
Shiva Kumar
Ranch Hand

Joined: Feb 09, 2001
Posts: 30
Calling main method of another from a class is possible only through invoking another JVM.
Runtime r = Runtime.getRuntime();
Process p = r.exec("java classname arg");
classname = Your Classname
arg = Argument for your classname if any
Michael Matola
Ranch Hand

Joined: Mar 25, 2001
Posts: 1746
I agree. Here's the link:
subject: Calling main method
Similar Threads
Running a class from command line
Doubt in inner class
Marcus Green's Mock question
extending a class and importing packages
Is it possible to override main method?