cetnar
cetnar

Reputation: 9415

How to include external configuration for webstart application

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.

Upvotes: 1

Views: 1968

Answers (4)

Tom Hawtin - tackline
Tom Hawtin - tackline

Reputation: 147164

You can get the codebase with BasicService.getCodeBase.

Upvotes: 2

Will Hartung
Will Hartung

Reputation: 118704

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.

Upvotes: 1

Gus
Gus

Reputation: 11

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.

Upvotes: 0

Mark
Mark

Reputation: 29129

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.

Upvotes: 0

Related Questions