0

Is it possible to start/run/execute a jar within an Applet? If it is possible, how can I do this?

2
  • this may help you docs.oracle.com/javase/tutorial/deployment/applet/… Commented Oct 24, 2014 at 14:51
  • 1
    Thats 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. Commented Oct 24, 2014 at 14:53

2 Answers 2

1

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 URLClassLoader for the URL.
  • Load the class and instantiate it.
  • Call the main(String[]) method.
Sign up to request clarification or add additional context in comments.

Comments

0

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.

3 Comments

I think you are right. I think the way you describe with signing, downloading and then starting is the way to go. Do you maybe have example code of that for me?
I already thought about this solution but I was not sure how to do it exactly. I will later use a offical signed Applet of course. Do you maybe have an example or sample code of how to do it then? Can I run "Runtime.getRuntime().exec("java -jar my_app.jar");" with a signed Applet? I already tried it on my local computer with adding this page to the sitelist but it did not execute this command. Is it because it is not signed?
Thank you very much for your answere. I solved the problem and got the jar to run in a applet, great!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.