Friday, March 9, 2012

Starting a Web Start application locally

Java Web Start is a technology that allows you to load your application from a http server. This has some advantages: the user doesn't have to install your application, you're sure that your users are always using the latest version of your application etc.. You can find more information on this technology at http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136112.html

To create a webstart application you need to create a JNLP descriptor. See http://docs.oracle.com/javase/1.5.0/docs/guide/javaws/developersguide/syntax.html for the syntax.
The codebase specifies the location where java can find your files (all resources in the jnlp file are relative to this path). When you deploy your Web Start application, this will be the location on the http server where you upload your application (eg: http://www.mysite.com/myapp).

When you're developing or testing your application, you don't want to upload it every time you make a change. Unfortunately, you can't leave the codebase blank. Leaving it blank will give you the following exception:
The field <jnlp>href has and invalid value:

So what should you put there? You can't put the path to your application (eg: c:/myapp), since that will leave you with the same error message.
Your next try might be file:///c:/myapp or file:/c:/myapp, which won't work either. The correct syntax is:
file://localhost/C:/myapp

Now you can test your Web Start application locally!