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 of how you can deploy Java applications.
In this tutorial, we 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. Project Kenai, which provides collaborative capabilities for developers, is used in this tutorial as an example of a remote web server to which you can upload application files.
This tutorial takes approximately 20 minutes to complete.
Contents
To complete this tutorial, you need the software and resources listed in the following
table.
Opening a Project
At first, you need to open an IDE project with the Converter application. The application source code is already packaged as a NetBeans IDE project, so you will just need to open it 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.
- Download the zip file that contains the Converter demo application packaged as a NetBeans IDE project.
Unzip the it to any location on your system.
- 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.

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
At first, we configure the project to make it Java Web Start enabled and test its execution locally.
- Right-click the ConverterPrj project node and choose Properties.
- Under Categories, choose Web Start and select the Enable Web Start checkbox.
- Leave the Local Execution option selected as the Codebase as we will first run the application locally.
The Codebase Preview field shows the path to local application files.
- Ensure that the Self-signed checkbox is selected.
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.
- (Optional). In the Project Properties dialog box, select the Applications panel and change the application title and vendor name.
- Click OK to close the Project Properties dialog box.

Compiling and Running the Java Web Start Application from the IDE
To compile and run the application to test Java Web Start locally:
- Right-click the ConverterPrj project node and select Set as Main Project.
- 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.
- Select the checkbox to trust the content and click Run in the warning window.
The Converter application starts.

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.
To view the files, open the Files window in the IDE and expand the dist folder. For Java Web Start, the following two additional files are created:
- launch.jnlp - This is an XML file with special elements and attributes that instruct browsers how to run the application. JNLP stands for the Java Network Launching Protocol. Attributes of JNLP files can include the JNLP spec version, application title, vendor name, a link to the application JAR file, etc.
- launch.html - This is an automatically generated HTML page that has a link to the JNLP file. Users click this link to start applications via Java Web Start. This generated HTML file also has a commented-out reference to the publicly available Java Deployment Toolkit (deployJava.js), which provides JavaScript functions in order to avoid browser compatibility issues. You can find more information about the Java Deployment Toolkit here.
You can try doing the following: outside of the IDE, navigate to the launch.html file on your system, open it in your browser and click the link to launch the Converter demo application.

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.
This tutorial shows you how to upload the application to Project Kenai, which provides collaborative environment for developers and allows its users to host and share open source projects and code. If you decide to follow our instructions on how to upload to Kenai, you will need a Kenai user account and a project. However, you might also choose to upload your application to any other web server.
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.
- Right-click the ConverterPrj project node, choose Properties and select Web Start under Categories.
- Choose User Defined as the Codebase.
- In the Codebase Preview field, enter the URL where you will be uploading the source files.
For example, http://kenai.com/projects/netbeans-java-docs/downloads/download/converter/
In our example, we are going to upload the application files to the netbeans-java-docs project on Kenai.
- Click OK in the Project Properties window.
- 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 Project Kenai 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. For more information about creating a project on Kenai, see Creating a Kenai Project in NetBeans IDE. For Kenai features, see Project Kenai Documentation and Training.
- Log into Kenai.com and navigate to the download area for your project.
In our case, the project title is "NetBeans IDE Documentation Area", and the link to the project's downloads is http://kenai.com/projects/netbeans-java-docs/downloads/
- Upload the following local files from your project's dist folder to the Downloads area of your project: ConverterPrj.jar, launch.html, and launch.jnlp.
The figure below shows the download area for the NetBeans IDE Documentation Area project. 
- Now, run your application. In a browser window, enter the URL to the launch.html file. In our case, it is
http://kenai.com/downloads/netbeans-java-docs/converter/launch.html and click the "Launch the application" link.
The Converter application starts with Java Web Start.
Summary
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.
As an example of a remote server where to host the application, we used kenai.com.
See Also
For more information about using Java Web Start, see the following resources:
For more information about Project Kenai and its integration with the NetBeans IDE, see: