Question

I want to serve up a dynamic JNLP with customized launch <argument> tags for a user.

After much hassle, it's almost working.

The user logs into the site, downloads a JNLP which is customized for the user. Java Web Start launches using the downloaded, customized JNLP file.

However, the first a user launches the app, Java Web Start fetches the "master" JNLP file from the server, by using the href attribute embedded in the .jnlp file. This doesn't contain the user's custom <argument> tag, and things break.

Is there a way to tell JNLP to use the local JNLP file and not fetch it from the server?

Here's my APPLICATION_TEMPLATE.jnlp:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Discriptor 1.5//EN" "http://java.sun.com/dtd/JNLP-1.5.dtd">
<jnlp
        spec="6.0+"
        codebase="http://localhost/jnlp"
        version="1234"
        href="http://localhost/jnlp/app.jnlp">
    <information>
        <title>JNLPHelper</title>
        <vendor>Yoyodyne, Inc.</vendor>
        <offline-allowed/>
        <shortcut online="true" install="false">
            <desktop/>
            <menu submenu="Yoyodyne, Inc."/>
        </shortcut>
        <association extensions="jnlphelper" mime-type="application-x/jnlphelper"/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <update check="timeout" policy="always"/>
    <resources>
        <java initial-heap-size="32M" max-heap-size="256M" version="1.6+"/>
        <!--<j2se version="1.6+" java-vm-args="-esa -Xnoclassgc"/>-->
        <jar href="JNLPHelper.jar"/>
    </resources>

    <application-desc main-class="com.prosc.msi.jnlp.JNLPHelper">
        <argument>*</argument>
    </application-desc>
</jnlp>

This example file is hosted on my webserver, which during testing is localhost. The user downloads a customized JNLP with <argument>foo</argument> replacing <argument>*</argument>.

I tried removing the href attribute entirely from the <jnlp> tag. This almost worked, but the application prompts to re-install itself each time, and my desktop icon is removed and re-added.

Was it helpful?

Solution

How are you determining the user? You will probably find it's a session issue or similar where the JNLP href is pointing to what turns out to be an uncustomised .jnlp response. You might want to change the way you figure who is using the download or allow your app.jnlp URL to take a parameter that confirms who the current user is?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top