Since the last security changes in Java 7u40, it is required to sign a JNLP file. This can either be done by adding the final JNLP in JNLP-INF/APPLICATION.JNLP, or by providing a template JNLP in JNLP-INF/APPLICATION_TEMPLATE.JNLP in the signed main jar.
The first way works well, but we would like to allow to pass a previously unknown number of runtime arguments to our application.
Therefore, our APPLICATION_TEMPLATE.JNLP looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="*">
<information>
<title>...</title>
<vendor>...</vendor>
<description>...</description>
<offline-allowed />
</information>
<security>
<all-permissions/>
</security>
<resources>
<java version="1.7+" href="http://java.sun.com/products/autodl/j2se" />
<jar href="launcher/launcher.jar" main="true"/>
<property name="jnlp...." value="*" />
<property name="jnlp..." value="*" />
</resources>
<application-desc main-class="...">
*
</application-desc>
</jnlp>
The problem is the * inside of the application-desc tag.
It is possible to wildcard a fixed number of arguments using multiple argument tags (see code below), but then it is not possible to provide more or less arguments to the application (Java Webstart will no start with an empty argument tag).
<application-desc main-class="...">
<argument>*</argument>
<argument>*</argument>
<argument>*</argument>
</application-desc>
Does someone can confirm this problem and/or has a solution for passing a previously undefined number of runtime arguments to the Java application?
Thanks alot!
The Java Network Launch Protocol (JNLP) file for rich internet applications (RIAs) is an XML file.
The JNLP file specifies the name of the main JAR file, the version of Java Runtime Environment software that is required to run the RIA, name and display information, optional packages, runtime parameters, system properties, and so on.
Click on Start and select Control Panel from the Settings menu (or click Start and select Control Panel). In the control panel, click Folder Options . In the Folder Options window, click the File Types tab. Locate JNLP under the list of registered file types.
From what I can see after reading the JNLP 7 specification, it appears what you want can't be done. The asterisk can only represent text data, not multiple XML elements.
In your situation, I would make the main
method capable of doing its own parsing of a single argument so it can be treated as multiple values, using a custom separator. Something like this:
public static void main(String[] args) {
if (args.length == 2 && args[0].equals("--args")) {
args = args[1].split(";;");
}
// Continue as normal
}
This allows the template to contain:
<application-desc main-class="com.example.app.Main">
<argument>--args</argument>
<argument>*</argument>
</application-desc>
And your the actual .jnlp file could contain something like:
<application-desc main-class="com.example.app.Main">
<argument>--args</argument>
<argument>files.txt;;29;;true;;1384212567908</argument>
</application-desc>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With