Macca Blog

My life experiences with code and design

Adding Java Web Start to your Blog for a JavaFX application

Posted on by Mark

I have been recently adding some JavaFX examples to my blog and I have wanted to also add a simple little link to the JNLP web start file and I really had no idea how to accomplish this on blogger.

The issues I had was the hosting of the files and the locations of the dependent JAR files.

After a quick google search and other various searches, I came up with a simple solution, Google Code Hosting.

Here are the steps that I used to achieve getting JNLP links on my blog…

Important Update:

The details below are for the both the preview release of JavaFX and the 1.0 SDK.

This blog posting is broken up into 2 main areas, preview-SDK and the 1.0 SDK. Each with there own methods to including a JNLP file into your blog.

If you are still using the preview release of JavaFX, I highly recommend you update to the 1.0 release ASAP to avoid having the issues highighted in the preview-SDK section of this post.

1.0 JavaFX SDK details
To create a working JNLP file and use it on a blog, such as this one, you simply need to create any old JavaFX project within Netbean 6.1 and build it.

Netbeans 6.1 will create a JNLP file that has most of the details that you will need in order to get your application working.

The generated JNLP file references an online JNLP file that has the references to the JAR files you will need to run your application.

Once you have the JNLP file created for you, feel free to edit some of the details, like description, homepage, etc… as you like. You now need to get ready to upload the file to the rest of the world to see.

Using google code hosting, you can easily upload your files for others to download an use.

I have created a project called markmacumber-jnlp that I use to host my files for others to download.

The download location for the files will be like this for my project:

Knowning this, you need to simply update your JNLP file to use this location for its own references. The <jnlp> element has a href attribute you need to update to point to the directory it will sit on on the google servers, and the <jar> element within the <resources> element will need to also point to the location of your main JAR file once you upload it to the google server.

Below is an example of a JNLP file with the updated values:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" href="">
<title>Name of Application</title>
<vendor>Mark Macumber</vendor>
<j2se version="1.5+"/>
<extension name="JavaFX Runtime" href=""/>
<jar href="" main="true"/>
<application-desc main-class="..."/>

The last thing to do now is to upload the JNLP to the servers and away you go…


Preview-SDK details

New Google Code Project

I created a new hosting project called markmacumber-jnlp that I could use for all my distributed apps.

Then I uploaded all the JavaFX JAR files to the downloads tab one at a time. Luckily, this is a once off job as there are 12 JAR files (which seems like a lot to me, I am currently finding out which ones are actually needed). However, this is only as issue with the preview-SDK, as the 1.0 SDK release fixes this with a reference to an online JNLP file which contains all the required JAR files.

Netbeans Webstart deployment

I then needed to get netbeans 6.1 to allow me to create a JNLP file for distribution.

To do this, you just need to enable webstart on your project.

  1. Right Click on the project –> Properties
  2. Under the Applications item, click on the WebStart item
  3. Click “Enable Web Start
  4. Under the Run item, click “Run with Java Web Start

Then do a clean build and netbeans will create a JNLP file called: launch.jnlp under the /dist directory of you project.
(as well as the JAR files required to run the app).

The JAR certificate issue

When you do a build of the web start application, the JAR files that are under the /dist/lib directory are signed by netbeans, and the certificate used by netbeans is different for every application that you build.

This means that, although the JAR files under the /dist/lib directory are exactly the same for different projects, they are signed by a different certificate.

If you try to run a JNLP file using the JavaFX jar files under a common lib directory (say hosted by google code as I have done). You will get the error:

JAR resources in JNLP file are not signed by same certificate

this error gave me a lot of grief for a while, as I could not find out how to get around it. Then I came across another blog by Peter Davison with the same issue. Link.

The solution was to change the JNLP file, to, instead of using the <jar> element under the <resources> element, you use the <extension> element instead, which points to another JNLP file altogether. This gets around the certificate issue nicely.

An example JNLP file using this technique is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" href="">
<vendor>Mark Macumber</vendor>
<description>Mouse Orientation - Simple app that shows some nice mouse orientation usage in JavaFX</description>
<description kind="short">Mouse Orientation Demo</description>
<homepage href=""/>
<j2se version="1.6+"/>
<jar href="" main="true" download="eager"/>

<extension name="Scenario" href=""/>
<extension name="gluegen-rt" href=""/>
<extension name="javafx-swing" href=""/>
<extension name="javafxdoc" href=""/>
<extension name="javafxgui" href=""/>
<extension name="javafxrt" href=""/>
<extension name="jmc" href=""/>
<extension name="jogl" href=""/>
<extension name="javafxc" href=""/>
<application-desc main-class="mouseorientation.Main">

As you can see above, this is the main JNLP file that is used to launch my sample app, “Mouse Orientation”, that I have made. The only <jar> element under the <resources> element is the reference for the main JAR for the app. The rest of the resources are all <extension> elements which point to other JNLP files which, themselves, reference JAR files.

Below is an example of one of those JNLP files (lib-javafxc.jnlp):

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" href="">
<title>javafxc.jar</title> <vendor>Sun Microsystems</vendor> <description />
<security> <all-permissions/> </security>
<jar href="" download="eager"/>

The above is pretty simple, just points to the jafafxc.jar file which I uploaded earlier in the blog.

Comming Together

Once you have updated your main JNLP file to use the <extension> elements for the dependent JAR file, you just need to then upload your main JNLP file, and the main JAR file.

It should be noted that in the main JNLP file there is the root <jnlp> element which has a href attribute, this points to the uploaded location of the JNLP file.

You then just need to post the link to the file such as:

The main benefit of this approach is that you will only need to upload the dependent JAR’s for each of your JavaFX apps once, then just a minor update to your generated JNLP file from netbeans, and a quick upload, then your done!

Here is a quick summary of the things you will need to get webstart apps available to you and under your control under the preview-SDK.

  1. Create a Google Code Project
  2. Upload your dependent JAR files (to the downloads tab in you new project)
  3. Create separate JNLP files for each of the above JAR files and upload them
  4. Get netbeans to create your JNLP file for you, and alter it to use the above JNLP files
  5. Upload your main JNLP file and main JAR file
  6. Profit??

Please remember to read the important update to this post before reading each of the two sections so that you know where you are…

I hope that this makes sense, I am relatively new to Java Web Start, so if anyone has any improvements or suggestions, I would be happy to hear them.

This entry was posted in Deployment, Jar, Java, JavaFX, JNLP, Netbeans, Web Start. Bookmark the permalink.

2 Responses to Adding Java Web Start to your Blog for a JavaFX application

  1. pbsl

    you have nice site. thanks for sharing this site. various kinds of ebooks are available here

  2. nice to be here…. thanks for share Your site is very useful for me .I bookmarked your site!

Leave a Comment

Your email address will not be published. Required fields are marked *