In 2000, Sun Microsystems introduced Java Web Start with a minimum of fanfare. Web Start was positioned as a way to make it easier to get Java applications running on end-user machines. Web Start has done that somewhat, and with its inclusion in all Java 1.4 VM downloads, it’s doing an even better job. But Web Start really shines in the deployment of frequently updated applications, specifically internal development tools.

Application launching with Web Start requires a few things be available:

  • ·        A Web server
  • ·        Signed Java Archive files (JARs) containing the application
  • ·        A valid Java Network Launching Protocol (JNLP file)

The Web server
To run the development tool through Web Start, users must be able to access the common Web server that will be serving up JAR files and a .jnlp file. It must be configured so that the JNLP file is provided with a “Content-Type:” header indicating a MIME type of application/x-java-jnlp-file. Configuration details differ according to Web server and operating system, but for most Apache on UNIX installations, it’s as simple as adding a line to the /etc/mime.types file.

Signed JARs
The application that is to be made available through Web Start will need to be compiled into signed JARs and placed on the Web server. If your normal build system is Ant, you can easily add a JAR and sign tasks to produce these JAR files. Locations not using Ant will need to use a scripting solution to check out source, compile and sign the JARS, and deliver them to the Web server.

However, before Ant or a script can be used to sign JARs, the Java keytool application must be used to create a key for signing. The command-line syntax for key creation is:
keytool -genkey -keypass mypassword -keystore mystore -storepass anotherpass

where mypassword and anotherpass are passwords that everyone in the team may know. The parameter mystore can be any file path so long as the file is accessible by the build tool that will be signing the JARs. All JARs required by the application must be signed, including third-party libraries.

The JNLP file
A JNLP file is an XML document that describes the application to be launched by Web Start. The format of a JNLP file is quite simple and has few required elements. The example found in Listing A launches the Notepad application hosted on Sun’s site. The codebase attribute within the JNLP element resolves any relative URLs in the rest of the document. The href attribute specifies the location where the JNLP document will be made available. Elements within the information element are obvious but required. The JAR elements within the resources element tell Web Start where it can find the signed JARs created above. The full JNLP file specification can be found on the Web Start Developer’s Guide.

Deployment
Once the Web server, signed JAR, and JNLP are in place, transitioning developers over to running tools through Web Start is as simple as having them download the Web Start application from Sun’s Web Start product page. They can then launch the tool simply by navigating their browsers to the URL of the JNLP as hosted on the Web server. Web Start will take it from there. What’s more, the auto-updating features of Web Start will make sure developers are always running the most current version of any tools made available. For more information on updating Web Start, check out this Unofficial Web Start FAQ.


Start your engines

Have you used Web Start? Post a comment below or send us an e-mail.


 

Subscribe to the Data Insider Newsletter

Learn the latest news and best practices about data science, big data analytics, artificial intelligence, data security, and more. Delivered Mondays and Thursdays

Subscribe to the Data Insider Newsletter

Learn the latest news and best practices about data science, big data analytics, artificial intelligence, data security, and more. Delivered Mondays and Thursdays