Java Web Start Problems

J

JavaEnquirer

I have a Java application which runs fine when launched from the
command line, picking up any args that I pass.

This application also launches using Java Web Start, except for the
fact that any args passed in the <argument> tags of the jnlp file seem
to end up as null when referenced from the main method.

Has anyone experienced similar problems? Here's the jnlp file:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://fitits010162:8080/moose"
href="mapping.jnlp">
<information>
<title>Demo Application</title>
<vendor>Blah</vendor>
<homepage href="help.html"/>
<description>An App</description>
<description kind="short">A description</description>
<icon href="1.gif"/>
<offline-allowed/>
</information>

<security>
<all-permissions/>
</security>

<resources>
<j2se version="1.5"/>
<jar href="mapping.jar"/>
</resources>

<application-desc>
<argument>DAVID</argument>
<argument>JONES</argument>
</application-desc>

</jnlp>

Also, I've tried putting the argument values in single and double
quotes, tried different numbers of arguments and different types, but
to no avail. Tried values with an without spaces and escaping with %20.
Also, tried referenceing the main class in the <application-desc> tag
etc etc etc

Remeber, the app launches, but the arguments get lost somehow?

Many thanks in advance!
 
A

Andrew Thompson

This application also launches using Java Web Start, except for the
fact that any args passed in the <argument> tags of the jnlp file seem
to end up as null when referenced from the main method.

Has anyone experienced similar problems?

No, but just as a test, I made up a quick Java source and JNLP.

<sscce>
package test;

import java.awt.*;
import javax.swing.*;
import java.net.*;

public class JNLPArgumentsTest {

public static void main(String[] args)
throws MalformedURLException {

JFrame f = new JFrame("JNLP Arguments Test");
String[][] propertyValue = new String[args.length][2];

for (int ii=0; ii<args.length; ii++) {
propertyValue[ii][0] = args[ii];
try {
propertyValue[ii][1] = System.getProperty(args[ii]);
} catch (java.security.AccessControlException ace) {
propertyValue[ii][1] = "not accessible";
}
}

JTable table = new javax.swing.JTable();
table.setModel(new javax.swing.table.DefaultTableModel(
propertyValue,
new String [] {
"Property", "Value"
}
));

Container c = f.getContentPane();
c.setLayout(new BorderLayout());

c.add( new JScrollPane(table), BorderLayout.CENTER );

f.pack();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setVisible(true);
}
}
</sscce>

JNLP
************************************ : start
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://www.physci.org/test/jnlpargs/"
href="jnlpargs.jnlp">
<information>
<title>JNLP Arguments Test</title>
<vendor>Blah</vendor>
<description>JNLPArgumentsTest App</description>
</information>
<resources>
<j2se version="1.5"/>
<jar href="argtest.jar"/>
</resources>
<application-desc main-class="test.JNLPArgumentsTest">
<argument>java.version</argument>
<argument>user.home</argument>
</application-desc>
</jnlp>
************************************ : finish

The JNLP is exactly as I was using it, except for that I
was diong it off the local filesystem, with the codebase
URL changed accordingly.

(shrugs) It worked. The two arguments reached the main
as valid values. In the unsigned form that I prepared it,
the "user.home" was not accessible, but "java.version"
returned 1.5.0_03.

Try it your end and see if you can get that to work.

[ And you might also
- supply an URL to help debug such matters, and
- exclude trivial elements from the JNLP like
'icon' and 'description' elements.. ]
 
A

Andrew Thompson

<application-desc>

<based on a hunch>
BTW, try specifying your 'main-class' attribute here,
rather than default to the manifest. Any difference?
</based on a hunch>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,470
Messages
2,571,809
Members
48,797
Latest member
PeterSimpson
Top