TaT CompileJNLPprojects

Resolve References to compile JNLP projects with NetBeans 6.x

[[{TableOfContentsTitle=TableOfContent} | {TableOfContents title='Table of Content'}]]


This is a pretty simple issue that was easy to solve but took a bit of fumbling around…

I recently checked out the new Java SwingSet3 project from its SVN repo, to play around with it. It’s a NetBeans project so it was simple enough to fire up NetBeans 6.0 and use its built-in Subversion support to check the project out from the repository directly…

My plan was very simple: Check out the code with NetBeans, build it, run it (using JDK 1.6.0_10 beta for the new Nimbus look/feel too) and then hack at the code.

Problem Description

Small problem: Once the project is checked out and loaded, NetBeans pops up a warning dialog:

File:Fig 0. NetBeans Reference Problems alert box

Also the Projects view shows errors, and if you drill down to them, it's because NetBeans can't find the javax.jnlp package. Hmm, I thought JNLP was included with the JDK since 1.5? How odd...


To make a long story short, the fix is to do the following steps (an explanation comes later):

  1. Resolve Problems by right-clicking the SwingSet3 project in the Projects view and choosing the "Resolve Reference Problems..." menu item:
  1. This opens a dialog listing the problem (there should be only one). Press the "Resolve..." button at the right:
 File:Fig 2. Resolve Reference Problems dialog. Press Resolve... button
  1. NetBeans presents a dialog listing libraries and JARs. Our issue is that the SwingSet3 project has defined a library called "JavaWebStart" but if you look in the tree at left, there is no such library defined in NetBeans by default. No worries, let's make one:
  2. Press the button at bottom ("New Library..."):
 This gives you the same dialog you get via Project Properties > Libraries > Add Library > Create  (in case you want to repeat this exercise later, or are starting a JNLP project from scratch...).
\ Give the new library the name that the Project wants ("JavaWebStart" in the case of SwingSet3). It'll be a Class Library.
  1. Now you need to tell NetBeans about the JARs that belong to the library:
 We need jnlp.jar, but might as well add the other Java Web Start stuff to the library too. You can find these JARs in your JDK under <JDK_HOME>/sample/jnlp/servlet. Add all the JARs form this directory (jnlp.jar,jnlp-servlet.jar, jardiff.jar):
  1. Add your new library to your project's Compile Libraries and you're done:
 File:Fig 6. Resolved, click Close button.

In the SwingSet3 project, there's also a broken reference to C:/java/jnlp1.2/jnlp.jar, but I don't think this matters (it compiles without the reference). You can probably remove it from the project.


Now, what happened? It seems that the project file I checked out in this example contained a reference to a non-standard NetBeans library called "JavaWebStart". This was probably defined by the project coders to refer to the JWS class libraries. For some reason, although the JWS JNLP libraries ship as part of the JDK since 1.5, they are in the Samples directory. Why Sun chose to distribute the libraries in the samples and not in <JKD_HOME>/lib is a mystery to me... it causes two problems:

  • Development libraries for JNLP are not accessible by default, unlike other javax.* packages... so you'll need to go through this learning curve.
  • If you chose not to install the samples with your JDK, you won't have jnlp.jar, and will need to add it (using the JDK installer, if you still have it), or download the Java Web Start Developer's Kit (which also mentions it's included with the JDK since 1.5...)

Anyway, problem's solved once your IDE knows how to find the library and JAR...

What about other projects?

You only have to define the library once. After you've added your "JavaWebStart" library to NetBeans, you can use the library for other projects requiring JWS/JNLP too:

  1. In Projects view, right-click on Libraries and select "Add Library..." from the pop-up menu
  2. Chose "JavaWebStart" from the library list and press the "Add Library" button.
  3. Observe that the new JARs are now listed under the Libraries node of your project


  1. Java SwingSet3 project
  2. Subversion support in NetBeans
  3. Java Web Start Developer's Kit
  4. Original blog post for this article


Mike Lockhart

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo