Search code examples
javaxmlcommand-line-argumentsjnlpjava-web-start

Using JAR parameters in JNLP file


I have a question how to run JAR files with the parameters using a JNLP protocol . For example, to properly run the selenium-server-standalone-2.21.0.jar package I call it as:

selenium-server-standalone-2.21.0.jar -timeout 60000 -trustAllSSLCertificates -port 5555 

When I add these parameters as:

<jar href="/selenium-server-standalone-2.21.0.jar -timeout 60000 -trustAllSSLCertificates -port 5555"/>

I'm getting error - no such file found. I guess that these parameters are treated as part of the file name and for this reason I got this error. Where can I place the parameters for the call JAR package in XML below.

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://test.com/">
<information>
  <title>Selenium-Server-Standalone-2.21.0</title>
  <vendor>ESKY Testers Toolkit</vendor>
  <homepage href="http://www.esky.pl/"/>
  <description>starts selenium server on client machine</description>
</information>
<security>
  <all-permissions/>
</security>
<resources>
  <j2se version="1.4+"/>
  <jar href="/selenium-server-standalone-2.21.0.jar"/>
</resources>
<application-desc main-class="org.openqa.selenium.server.SeleniumServer"/>
</jnlp>

Solution

  • Add arg elements as children of the application-desc element. E.G.

    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://test.com/">
    <information>
      <title>Selenium-Server-Standalone-2.21.0</title>
      <vendor>ESKY Testers Toolkit</vendor>
      <homepage href="http://www.esky.pl/"/>
      <description>starts selenium server on client machine</description>
    </information>
    <security>
      <all-permissions/>
    </security>
    <resources>
      <j2se version="1.4+"/>
      <!-- size.  The downloadable size of the JAR file in bytes. -->
      <jar href="/selenium-server-standalone-2.21.0.jar" size="21247" />
    </resources>
    <application-desc main-class="org.openqa.selenium.server.SeleniumServer">
        <argument>-timeout</argument>
        <argument>60000</argument>
        <!-- etc... -->
    </application-desc>
    </jnlp>
    

    Former comments (now deleted).

    • Uninstall the app. before testing the new JNLP. The launch files can be very update resistant. In fact, when changing the JNLP - I'd generally change the cache location (via the Java Control Panel) to test the new launch file.
    • JNLP. Check the (well-formedness and) validity (amongst other things) of the launch file using JaNaLA. Correct any errors in pink/red before proceeding to another test.