Delivering your ArcGIS Runtime Java Apps with Java Web Start

We often get asked if applications built with Esri’s ArcGIS APIs can be used with Java(tm) Web Start. The answer is ‘yes’, but people still experience a “trial and error” process, unfortunately. In a sincere effort to try and clarify how to use Java Web Start to deliver your ArcGIS Runtime Java apps, here is a simple deployment scenario that we hope you will find informative.

About Java Web Start

Java Web Start is an application deployment technology that is widely used throughout the Java development landscape. Rich, standalone Java applications can be deployed with a single click over the network using Java Web Start Technology. Java Web Start ensures the most current version of the application will be deployed, as well as the correct version of the Java Runtime Environment (JRE). For more detailed information about how it works and the Java Network Launching Protocol (JNLP) specification, go to http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136112.html

A Simple Example

I developed a simple ArcGIS Runtime Java application that is to always be connected. In other words, it will not use a “local” runtime and will never be disconnected from the internet in any way. Therefore, all of the business logic for the application will be running in Java, accessing a Web Map from ArcGIS Online, and the application is made up solely of a handful of jar files.

I found a machine to act as my target for delivering my app to and installed the Java SE Runtime Environment v7.x.

For my development environment, I started out with the code in Netbeans 7.2. I configured my project to use Web Start as the start-up mechanism by simply right-clicking on the project and selecting “Set Configuration–>Web Start”. By the way, Netbeans is not a requirement for using Java Web Start. I chose this approach because of Netbeans’ built-in tooling for setting up your Java Web Start environment automatically. In other words, I’m lazy! .

Set up your Netbeans project to run as with Java Web Start

Now, I was able to run my application from within Netbeans, which performed the needed tasks for making a Java Web Start deployment:

  • generated my JNLP file
  • compiled my code into an executable jar
  • signed the jar and all dependent jars
  • copied everything into a single location for distribution.


Let me briefly describe these. (You can disregard the jnlpcomponent1.jnlp file, as this is an artifact of Netbeans, and not essential to this topic):

The jar called “WebStartTest.jar” contains all of my application logic. The “lib” folder contains all of the application-dependent jars, including the ArcGIS Runtime jars. All of the jars are digitally signed, a requirement for Java Web Start to securely execute Java classes on the target machine.

The “launch.jnlp” file is what launches the Java app from a Web URI, for example, “http://mywebserver/weatherapp/launch.jnlp”. It tells the Web Server to grab the specified app jars and stream them to the client machine so they run locally. The JNLP file is simply an XML file, used to provide the Web Server and the target machine’s Java Runtime Environment with the instructions on how to deliver the app to the target and execute the app. I recommend spending a little time reviewing the JNLP specification for an explanation of the tags.

The “launch.html” file is used as a launch site, which redirects to the launch.jnlp file.

After I verified that my application ran properly from within Netbeans using Java Web Start, I copied the generated “launch” JNLP, jars, and the “launch” html file from my Netbeans project “dist” folder into a folder on my Web Server. I named the folder “weatherapp”, the name of my application.

At this point, I should have been ready to launch my app by accessing the launch.html file over HTTP. However, there was one more vital step to take. I needed to edit the JNLP file (now located on the Web Server) to insert the “codebase” attribute into the <jnlp> tag, telling Java Web Start where to find the jars on the Web Server to be delivered:

<jnlp codebase="http://mywebserver/weatherapp/" href="launch.jnlp" spec="1.0+" >

That was it for the setup. In a Web browser of my choice I navigated to http://mywebserver/weatherapp/launch.html.

Clicking on the launch button on this page allowed the app to stream to the client machine and execute.

Weather Alerts app, launched from Java Web Start

Weather Alerts app, launched from Java Web Start

Summary

Your Java applications developed with the ArcGIS Runtime SDK for Java can easily be delivered to your users via Java Web Start Technology. Netbeans is a nice platform to use for jump-starting a Web Start deployment. It is capable of handling the jar-signing and JNLP file creation tasks.

This entry was posted in Developer and tagged , , , , . Bookmark the permalink.

Leave a Reply

2 Comments

  1. vaclamar says:

    Hi Eric,
    I am able run my Runtime Java Apps with Java Web Start, if I have ArgGIS Runtime SDK for java installed on the client. Is it possible to run ArcGIS Runtime Java Apps with Java Web Start with the “Runtime deployment package” as part of Java Web Start?
    Martin

    • Eric Bader says:

      Hi Martin,

      Very sorry for the long delay! I need to update this blog, as I neglected to mention a very important point of including the “arcgisruntime” folder along side the application jar.

      I hope you were able to get things working anyway.

      Thanks,
      Eric