How to run a .jar inside browser?

1.5k views Asked by At

I tried to execute a .jar using HTML or PHP.

In the first case I wrote the code below:

<applet code=Diagnostica.class 
     archive="Diagnostica/Diagnostica.jar"
     width="120" height="120">
</applet>

This way doesn't work cause the file Diagnostica.jar need to contain an applet I suppose.

So I tried the second option in PHP:

exec("java -jar Diagnostica/Diagnostica.jar");

This way it works. Diagnostica.jar starts outside the browser, but I want to start it inside the browser.

How can I do?

1

There are 1 answers

0
dhh On BEST ANSWER

If that file does not contain an Applet, I do not think you will be able to start it in the browser (have a look here).

Executing it via exec should work like executing it via the command line - but as you already noticed, it will be run on the server - not the client.

If it should run on the client, you'll either have to use a Java Applet or let the user download the jar-executable and execute it via command line etc.