Is it possible to start/run/execute a jar within an Applet? If it is possible, how can I do this?
- this may help you docs.oracle.com/javase/tutorial/deployment/applet/…Santhosh– Santhosh2014-10-24 14:51:10 +00:00Commented Oct 24, 2014 at 14:51
- 1Thats a different topic. I don't want to just start an applet, or pack a applet as jar. I really want a Applet that start another jar file.AliceInChains– AliceInChains2014-10-24 14:53:30 +00:00Commented Oct 24, 2014 at 14:53
2 Answers
Yes, it is possible (but not simple).
It would require a signed and trusted applet with a custom security manager to handle the security for the loaded archives. The steps would be along these lines.
- Set the custom security manager.
- Establish an URL to the Jar.
- Establish an
URLClassLoaderfor the URL. - Load the class and instantiate it.
- Call the
main(String[])method.
Comments
I ASSUME that you could ask this as well:
"Can a Applet start a Java class that was initialy not available in the Applets classpath?"
=> I would say no. Hence there are possibillities using Java the Applets security policys will deny required actions to do so (e.g. download/ store/ manipulate CP, call Jar in the context of the executing client).
So the only way i see is to have a signed Applet that is allowed to operate on the file system and thus will be able to download a remote Jar and start it.