Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Get a grip on JavaFX 1.2 for Rich Internet Applications

This review of JavaFX 1.2 for rich internet applications (RIA) includes details on the download, deployment, and new features of the software as well as an assessment of its competitors, including Microsoft Silverlight 3 and Adobe Flash.

I took a look at JavaFX 1.0 not long after it was released in this article. Two years have passed, and JavaFX has reached version 1.2, just released with significant changes to the language and the API. Applications created under JavaFX 1.1 must be recompiled and may need minor alterations.

The basic nature of JavaFX continues to be creation of GUIs (Graphic User Interfaces) in a declarative language format that defines interface components from Java's well developed "Swing" interface toolkit plus a variety of display effects including animation, vector graphics, audio tracks and video, all running in a Java JVM. Many of the new features in 1.2 are related to flashy display effects. There are also significant additions which will be useful in accessing Web services.

The JavaFX language creates computation functions in a style familiar to Java programmers, with classes extending base classes and implementing interfaces. Version 1.2 brings a new feature which may surprise you: the "mix-in" class declaration modifier. A mix-in class cannot be instantiated directly, rather like the java "abstract" class, but a custom class can extend any number of mix-in classes. Java has insisted on single inheritance in the class hierarchy. If you want multiple inheritance, here is your chance to try it. I wonder if mix-in may make it back to standard Java!

Downloading the JavaFX release
The JavaFX 1.2 sdk can be downloaded from this site, in a 46MB installer. As with previous releases of JavaFX, you can get a combined download of the NetBeans 6.5.1 IDE plus the JavaFX release. You can also download just the plug-in if you already have the latest NetBeans installed. Although one Sun Web page says Java JDK 5 is sufficient, this page says JDK 6 update 13 is the minimum for developers and update 14 is recommended. In addition to Windows (XP or Vista), Mac OS X is supported while Solaris and Linux versions are still in beta release.

The SDK includes extensive API documentation in a jazzed up version of the familiar JavaDoc presentation. Warning: not all online JavaFX reference material at the Sun sites has caught up with version 1.2, so be careful. Even the SDK documentation has large gaps, which I hope Sun will fill in as rapidly as possible. Perhaps they were feeling rushed by the competition. Fortunately the Sun developers and other enthusiastic programmers are active bloggers, so searching the Web can locate many useful examples.

Support for data feeds from Web services
As with GUI programming in any language, you must never use the programming thread which handles user inputs from a keyboard or mouse to execute long running tasks. The JavaFX API is full of tools for starting and controlling tasks. Of particular interest for programming Web service clients is the HttpRequest class in the javafx.io.http package. HttpRequest lets you specify a URL and HTTP method and start a request which will proceed asynchronously. Callback functions are defined so that your code will receive notification as the request is processed and the response is returned. HTTP methods GET, POST, PUT and DELETE are supported making it easy to access RESTful Web services.

Based on various blog posts by JavaFX developers, I was expecting version 1.2 to have something like a javafx.xml package with a DOM model class. This did not happen. Instead we have a generalized "pull" parser capable of parsing XML or JSON (JavaScript Object Notation) streams and notifying your code as data elements are found. Of course, it is straightforward to access the standard Java library for XML if you want to use DOM tools such as XPath. Furthermore, there are other developers of JavaFX libraries for XML and JSON.

RSS and ATOM are simple Web service "feed" formats for publishing small chunks of frequently updated information in well defined XML formats. JavaFX provides specific classes for interpreting events from an XML pull parser in terms of the RSS or ATOM standard information components. These classes make it easy to create "mashup" style applications which gather information from all over the Web.

Deploying your JavaFX application
Deploying as an applet in a Web page uses JavaScript to interpret the JavaFX application description and load it from a JAR file. Stand-alone applications are easily created using Java Web Start. This highly refined technology, also referred to as Java Network Launching Protocol (JNLP), is part of the standard Java environment. Using JNLP you can construct a Web page link which will download a JavaFX application definition file and install the application on the user's desktop using downloaded jar files. The NetBeans IDE provides support for packaging the application as either an applet or a JNLP application and creating the supporting files required.

What about the competition? 
Competition to be the technology of choice in the Rich Internet Application (RIA) field continues to be fierce. I consider Adobe the foremost RIA technology company due to the long history and huge installed base of the Flash browser plug-in and the PDF Reader. Desktop applications using Flash technology can be created with Adobe Integrated Runtime (AIR), now in version 1.5.1. Adobe is continuing an aggressive development schedule and has moved major chunks of the technology under open source licensing schemes. An active developer community has created a large number of AIR applications.

Microsoft's entry in the RIA field is called Silverlight, distributed as a browser plug-in. Similar to JavaFX, the user interface is created in a declarative XML format with programming logic taking advantage of the .NET framework. Support for downloading content from Web services in XML and JSON format, in addition to various graphic media formats, is a major advantage. Silverlight version 3, now in beta release, provides, among other improvements, a way to install a Silverlight application on a desktop.

To me, the surprise of the RIA race has been Google. The huge acceptance of Google Earth as a browser plug-in and desktop application shows what a tool dedicated to a particular kind of data, as opposed to the generalized tools discussed above, can accomplish. An enormous research budget and an appetite for innovation have created a huge number of desktop applications, gadgets and browser plug-ins.

Main page for JavaFX summary of 1.2 features JavaFX Script tutorial starts here. Adobe RIA technology home. Silverlight home page. Google developer tools

Dig Deeper on Topics Archive

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.