Enabling Java Web Start in the NetBeans IDE

Following the steps in this tutorial, you will learn how to configure your application so that it can be deployed using Java Web Start. Java Web Start is a technology that is used to run Java applications from a web browser with a single click. In short, Java Web Start is just another way that you can deploy Java applications.

In this tutorial you will use a simple Java application, a converter, which converts distance measurements between metric and U.S. units. The code for this sample application will be given to you for download, and you will need to configure project settings in order to launch it using Java Web Start. You can use any remote web server available for you to upload the application files.

This tutorial takes approximately 20 minutes to complete.


Content on this page applies to NetBeans IDE 6.9, 7.0, 7.1, 7.2 and 7.3

To complete this tutorial, you need the software and resources listed in the following table.

Software or Resource Version Required
NetBeans IDE 6.9, 7.0, 7.1, 7.2, 7.3
Java Development Kit (JDK) 6 or 7
Converter zip archive n/a

Opening a Project

You first need to open the Converter application in the IDE. The application is already packaged as a NetBeans IDE project so you only need to open the project in the IDE.

The source code for the Converter demo is originally provided in the Java tutorial. Refer to the Using Swing Components section of the Java tutorial to learn how to write this small application. In this tutorial, you will learn how to configure your project settings so that this Java application can be launched in a web browser.

  1. Download the Converter demo application zip archive.
  2. Extract the archive to a location on your system.
  3. In the IDE, choose File > Open Project from the main menu.
    The ConverterPrj project opens in the Projects window. You can expand the project's nodes to view the source files.

Image showing the contents of the ConverterPrj.

Configuring the Project to Enable Java Web Start

With Java Web Start, the user can launch a Java application by clicking an HTML link to a JNLP file for this application inside a web browser. The JNLP file, which is a special configuration file, instructs Java Web Start to download, cache, and run the Java application. To run applications with Java Web Start, it is enough to have a compatible version of the Java Runtime Environment (JRE) installed on the client machine. The installation of the Java Development Kit (JDK) is not required.

To enable your Java application to run with Java Web Start, you need to configure the properties of how the IDE should build the project. When Java Web Start is enabled in project properties, the IDE automatically creates a JNLP file and an HTML page with the link to the JNLP file, together with the JAR file.

Configuring the Project to Enable Java Web Start

In this exercise you will configure the project to make it Java Web Start enabled and test its execution locally.

  1. Right-click the ConverterPrj project node and choose Properties.
  2. Under Categories, choose Web Start and select the Enable Web Start checkbox.
  3. Choose the Local Execution option from the Codebase drop-down list as we will first run the application locally.
    The Codebase Preview field shows the path to local application files.
  4. Click Customize to open the Signing dialog box. Select the self-sign by generated key option.
    The application JAR file will be signed by a certificate that is generated automatically when the project is built. With the self-signed certificate, the application will be able to access the same resources from the computer as a regular application that is running locally. For example, the self-signed certificate allows an application to access local files and the network.
  5. Leave Enable Software Protections selected in the Mixed Code drop-down list and click OK.
  6. (Optional) In the Project Properties dialog box, select the Application panel and change the application title and vendor name.
  7. Click OK to close the Project Properties dialog box.

Image showing the properties of the ConverterPrj.

Compiling and Running the Java Web Start Application from the IDE

To compile and run the application to test Java Web Start locally:

  1. Select the ConverterPrj project node in the Projects window and then choose Run > Set Main Project > ConverterPrj in the main menu.
  2. Choose Run > Run Main Project or press F6.
    The IDE compiles sources and you should see the splash screen that Java is starting and the warning window asking you whether the signed application can be executed.


  3. Select the checkbox to trust the content and click Run in the warning window.
    The Converter application starts.

    Image showing the Converter application.

Exploring Java Web Start Files

Now let's take a closer look at the Java Web Start files that were created by the IDE during the build process (Run > Build Project).

To view the files, open the Files window in the IDE and expand the dist folder.

Image showing the files created for the Converter application.

For Java Web Start, the following two additional files are created:

Running the Application from a Remote Location

After you verified that the application starts successfully with Java Web Start from local sources, let's upload it to a remote location and launch it from there.

Note: For deployment of applications with Java Web Start on the web, the web server you are using should be able to handle JNLP files. The web server must be configured to recognize JNLP files as applications, i.e. the MIME type for JNLP should be added to the configuration of the web server. Otherwise, files with the JNLP extension will be treated as usual text files. For more information about web server configuration, refer to the Java Web Start Guide.

Modifying the JNLP File

To launch the application from the web, you need to provide a link to the applications source file on the web in the JNLP file.

  1. Right-click the ConverterPrj project node, choose Properties and select Web Start under Categories.
  2. Choose User Defined as the Codebase.
  3. In the Codebase Preview field, enter the URL where you will be uploading the source files.
    For example, http://mydomain.com/myuser/converter/.
  4. Click OK in the Project Properties window.
  5. Right-click the ConverterPrj node and choose Clean and Build.
    This IDE command deletes all previously compiled files and build outputs, recompiles your application, and builds output files with current settings.

Uploading the Source Files

Now we will upload the source files to the server and run the application from there. Note that all user credentials and project names referred to in this section should be replaced with your personal data.

  1. Log into the web server and navigate to the download area for your project.
    In our case, the project title is "NetBeans IDE Documentation Area"
  2. Upload the following local files from your project's dist folder to the directory of your project: ConverterPrj.jar, launch.html, and launch.jnlp.

    The figure below shows the download area for the NetBeans IDE Documentation Area project.

    Image showing the download area for the NetBeans IDE Documentation Project

  3. Now, run your application. In a browser window, enter the URL to the launch.html file and click the "Launch the application" link.

    The Converter application starts with Java Web Start.


In this short tutorial, we showed how you can easily make a Java application deployable over the web using the NetBeans IDE. This is just one way of how you can deploy Java applications.

Send Feedback on This Tutorial

See Also

For more information about using Java Web Start, see the following resources: