views:

226

answers:

4

I have webstart application that needs external configuration. Configuration must be external, because it will be changed manually by our customer. I considered adding another jar with this configuration. Application is signed and giving our keys to customer is not a option. I'm leaning towards placing this file to be accessible from web server.

How retrive codebase url from webstart application inside or is there a way to configure webstart jnlp file to add other file than jar to classpath?

I use maven for complete build, if it is a clue.

Any others ideas are acceptable.

A: 

Check out the jnlp syntax reference here: http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html

The important bit for you is the "Resources" tag:

<resources>
  <j2se version="1.4.2+" java-vm-args="-esa -Xnoclassgc"/>
  <jar href="lib/SwingSet2.jar"/>
</resources>

In the above example, SwingSet2.jar is added to the classpath. Need more jars on the classpath? Add another jar resource

<resources>
 <j2se version="1.4.2+" java-vm-args="-esa -Xnoclassgc"/>
 <jar href="lib/SwingSet2.jar"/>
 <jar href="lib/SwingSetSupplment.jar"/>
</resources>

I had exactly the same trouble with codebase. I ended up using a JnlpServlet (You'll have to google it.. I can only post one hyperlink :( ) to automatically include the correct codebase when it serves up the jnlp file, then add

<property name="app.codebase" value="$$codebase"/>

to the resources section.

Gus
A: 

If you use the JNLP Download Servlet you can pass the $$codebase macro into your application as a system property and this will give access to the codebase URL.

In our webstart application configuration is stored to the server using SQL but that could be a bit heavyweight for your needs.

Mark
+1  A: 

You can use the Java Preferences API to store external configuration data. This will be local to the persons machine. On Windows, it uses the Registry, on Unix is uses classic ".xyz" files.

You would be best having some UI on your app for manipulating this configuration (sending users to RegEdit isn't really a nice thing), but it doesn't have to be anything glorious. A Name/Value pair editor will do the trick. And use reasonable defaults for starting up an "unconfigured" app.

Will Hartung
This seems a very logical solution, and doesn't require network connectivity back to the originating server (post download)
Brian Agnew
+1  A: 

You can get the codebase with BasicService.getCodeBase.

Tom Hawtin - tackline