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.
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|
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.
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.
In this exercise you will configure the project to make it Java Web Start enabled and test its execution locally.
To compile and run the application to test Java Web Start locally:
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.
For Java Web Start, the following two additional files are created:
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.
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.
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.
The figure below shows the download area for the NetBeans IDE Documentation Area project.
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.
For more information about using Java Web Start, see the following resources: