Thursday, October 4, 2012

JavaOne 2012: Mastering Java Deployment

After grabbing an Italian Classic Combo for another JavaOne 2012 lunch, I headed to Hilton Imperial Ballroom B to see the presentation "Mastering Java Deployment." The speakers, both from Oracle, were Mark Howe and Igor Nekrestyanov.

Howe stated that a goal of the deployment team is to help Java developers deploy their applications to platforms of choice. He started by discussing "feature deprecation." In some cases, there are multiple ways to do the same thing. An example of this is jarjar and pack200. By deprecating redundant (especially older) approaches, they don't have to spend as much time supporting and fixing bugs on these seldom used things.

Howe showed a table of features being deprecated and removed in JDK 7, JDK 8, and JDK 9. In general, anything being deprecated and/or removed has alternatives and folks using the deprecated/removed features should start looking at which alternative works best for them.

As of JRE 7 Update 6, a totally Oracle-supported JRE will be issued for Mac OS X. Oracle's intention is to fix bugs and add features across JVMs for all deployment environments at the same time. The JRE 7 is "mostly compatible" with Apple's JRE 6. One change is to be more aligned with Oracle's JVM support for other platforms and have Oracle's updated update the JRE on Mac OS X rather than using the Mac "Software Update." One caveat is that "Chrome on Mac is currently unsupported (32-bit only)."

In continuing the theme of platform JVM feature polarity, JavaFX is now delivered with JRE for Linux. Howe's "Convergence of Java and JavaFX" slide showed a table indicating the progress of converging Java and JavaFX versions. The goal is for JavaFX to be one of the core libraries in the Java specification. Plans for JDK 8 include "Java launcher able to run JavaFX applications" and "jfxrt.jar on boot classpath for java and javac."

Howe introduced the Java Deployment Toolkit and described it as a "tool to simplify deployment of Java content in the browser." He contrasted deployJava.js ("original version") with dtjava.js ("better JavaFX support and portability"). The dtjava.js version "supports all deployment scenarios on all platforms" though there is no autostart on Mac or Linux.

Howe talked about WebStart and explained that "user experience is not quite as nice as you'd like it to be." He contrasted this with use of dtjava.js that allows developer to set parameters for control of launching from JavaScript. It makes for more control and better user experience. This also removes need for fixed code base. The code shown in a slide for using dtjava.launch requires JRE 7 Update 6 or later.

The goal of packaging tools is to "simplify deployment for application developers." The command-line tool bin/javfxpackager (or set of Ant tasks lib/ant-javafx.jar) can be used with JDK 7 Update 6. The "latest release of NetBeans" supports these.

Howe covered several motivations for completely self-contained applications. A self-contained applications contains "all the artifacts necessary to run your application." It has a private copy of the Java runtime and removes the dependency on the external JRE. Many of the motivations for self-contained applications revolved around issues of acquiring a current JRE to run the application.

Benefits of self-contained applications include the feeling of a native application, improved compatibility, easier deployment on a fresh system, optional administrative privileges, and support of newer distribution channels such as the Apple Apps Store. The caveats of self-contained applications include larger size (JRE included), "download and run" instead of WebStart's "click and launch," need to build package per platform, and other current limitations such as package needing to be built on the target platform and application updates being the responsibility of the developer."

To create a self-contained application, one needs JDK 7 Update 6 as well as optional third party tools such as WiX to build MSI on Windows. Howe showed a slide with Ant code for generating the self-contained application. The Developer Preview will allow a developer to select target version of JVM (current choices are JRE 7 Update 6 or JRE Update 10). The Developer Preview is expected to be available with JRE 7 Update 10. JDK 7 Update 10 is also anticipated to support Mac App Store support.

Like so many other presentations at JavaOne 2012, community feedback was solicited. In this case, the deployment team would like to know what people want and need for more effective web deployment of Java applications. Howe had a nice slide comparing executable JAR to WebStart to self-contained application.

Mac App Store does not allow applications to "rely on optionally-installed technology." Other requirements include need for application to "run in a sandbox" and "follow UI guidelines." Certain APIs (FileChooser) should be avoided. See JavaOne 2012 slides for "Deploy Your Application with OpenJDK 7 on Mac OS X" and future version of JavaFX Deployment Guide for more details.

Howe's "key points to remember" include merging of Java with JavaFX, new platforms for Java, new deployment options (self-contained application bundle and deployment to Mac App Store), and deprecation of old deployment features.

One of the attendees asked if there is a way to share a single JRE among multiple shared self-contained applications. The answer is that there currently is not a way to do this, but that a JRE can optionally not be included in the otherwise self-contained application.

In responses to another question, the speakers stated they are not aware of any plans to deprecate Swing. They also responded to yet another question that there is currently no Maven support for building self-contained applications (use Ant or NetBeans).

There were several good slides shown in this presentation that I'd like to look at more closely in the future. Fortunately, Howe stated that these will be made available. Much of what was covered in this session will be open source and audience members were encouraged to contribute to the open source projects.