Running JAR by Browser

Asked

Viewed 2,686 times

11

I’m having a hard time figuring out how to do it:

What I Wish

I want to create a Google Chrome/Firefox extension that when I press a button in the html of my extension, it will run a file. JAR passing user settings parameter in the extension. So I thought about using JNLP.

Problem

But from what I understand of JNLP it executes the JAR directly from the server, and what I really wish is that it execute a JAR on the client’s machine this JAR will be already in a folder within the extension itself minhaExtensao/lib/foo.jar

Doubt

It would be possible to execute it so on the customer’s machine?

  • I believe you’re looking for are Applets.

2 answers

6


Take a look here http://java.sun.com/docs/books/tutorial/deployment/jar/run.html

I believe that just create as the example below in the html of your plugin.

<applet code=TicTacToe.class 
        archive="TicTacToe.jar"
        width=120 height=120>
        <param name="param1" value="value1">
        <param name="param2" value="value2">
</applet>

Take the test and put the results here, I’ll try to make one too.

  • Whoa, I’m gonna try!

  • 2

    A detail, the direct use of the tag applet is no longer recommended (in HTML 5 the tag applet is no longer supported, there are alternative syntaxes with tags object and embed). The best way to distribute an applet nowadays is through the Deployment Toolkit, which, among other things, generates the correct tag for each browser / doctype and checks if the user has a compatible JVM version (suggesting installing a Java version if it is not found).

2

The JNLP does not execute the code on the server, it is a protocol done exactly to allow the distribution of applications to clients (i.e., among other features, JNLP allows a client to download and run an application locally). I recommend the official tutorial from Oracle on Applet Deploy, as well as the way Deployment in-Depth. By the description of your requirements however I would go beyond an Applet, I believe you are looking for the Java Web Start and the infamous button Botão de Lançamento (that can be replaced by any other image).

  • So, but I want the client to download and run it locally. Because this software will have to use the client’s resources.

  • 1

    @ralfting. That’s what JNPL and Web Start do. They install the application on the client, and as per the permissions you request (by signing the code) you can have full access to the client’s resources (file systems, network, etc.). The software does not run on the server, but on the client’s machine.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.