wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes To execute java application from jsp or applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "To execute java application from jsp or applet" Watch "To execute java application from jsp or applet" New topic
Author

To execute java application from jsp or applet

Alex Janson
Greenhorn

Joined: Dec 30, 2003
Posts: 2
I am unable to execute any application’s main() method) from an applet or servlet, even though I can execute a public method from the same application. Anybody would help, I would really appreciate.
Does it suppose to execute the main method if I instantiate it?
(For me it does not exeute it.)
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Alex,
If I understand your question correctly, you are indicating you have an applet (say MyApplet) and you are trying to execute the main() method of a class (say MyClass) but are failing; but you can have MyApplet execute a public method in MyCalss.
That is exactly what should happen. The purpose of a main method is to start an application. Applications with 1 class or 10,000 classes both only have one main method. In the case of an applet, when the applet is loaded, the browser or applet viewer calls the applet�s init() method. You can think of an applet�s init() method as basically being the applet�s main. At this point your �application� is running (although be it as an applet) and it does not make any sense to call a main method within the same application.
The same holds true for Servlets. It all starts with the init method.
I hope that answers your question. If not, please clarify so I or someone else can help you out.
Regards,
Mark
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Alex!
I am unable to execute any application�s main() method) from an applet or servlet, even though I can execute a public method from the same application.
Why do you want to do such a thing? Could you post some example code of what you're trying to do?
Does it suppose to execute the main method if I instantiate it?
No. The main method is either invoked by the JRE when the program is started with a call to java or javaw, or when another program explicitly invokes the main method.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To execute java application from jsp or applet