Sun's JavaFX: Is it Java? JavaScript? Or something new?

Download JavaFX for Windows (all versions) from FileForum now.

We're told that the future of applications relies on app servers and rich, graphical clients. But will market share or common sense determine which method of building RIAs that developers choose most?

All the major rich Internet applications platforms that are in active use today are leveraged upon some existing, already well-deployed component. Adobe's AIR relies on the ubiquity of Flash video and the underlying language constructs that have supported Flash in the past, such as Flex. Microsoft's Silverlight is a vehicle for extending a part of the .NET Framework and Common Language Runtime -- and thus with them, a little bit more of Windows -- into everyone's computing environment; and once Microsoft secures that open pipeline, it may be able to push C# and other technologies through it.

Up to now, Google has been the one with the RIA platform that has tried to leverage Java, along with JavaScript (which is related in style but not in architecture, and which is essentially a product of Mozilla). Google Web Toolkit uses Java tools as a staging ground for Asynchronous JavaScript (AJAX) applications. Mozilla has been testing the waters for some time with its own RIA platform experiment called XULRunner; and Curl has had the wherewithal to go it alone, with both a development environment and a runtime that rely on no single pre-existing platform. (Some dispute whether AJAX truly qualifies as RIA, but I tend to say that if an application can run outside the browser with full graphical resplendence, as though it had been installed on the user's computer directly, then it's an RIA.)

To this mix of players, enter Sun Microsystems. Its JavaFX platform formally exited beta on Monday, and its objective is to further extend the Java 6 runtime platform onto more systems. Rich graphical applications built with JavaFX, like other Java apps since the 1990s, can run outside of the Web browser though maintain their links to servers through HTTP.

But JavaFX Script -- the programming language for this new platform -- is not Java, and it's not JavaScript. While it's not exactly a foreign language, especially for Web developers who find themselves learning new ones practically every month, it is -- like Flex for Adobe -- its own beast.

An example application using Sun's JavaFX

In this sample JavaFX application running in Java 6, a series of thumbnails can be browsed like a certain familiar long list of square covers, with each cover transforming itself in 3D and smoothly scrolling.

Rather than rely on some XML-based resource to define the appearance of on-screen objects, JavaFX Script uses an entirely new declarative language. In Java itself, you may use functions as a way of generating graphic objects, and arguments to those functions as ways of loading elements of those objects with text and values. By comparison, in JavaScript, you rely on XHTML markup to generate the placement and content of objects, which then sets up the environment for the events necessary that JavaScript can respond to with event functions.

With JavaFX instead, you declare the existence of graphic objects, which have very replete lists of properties. Rather than saying those properties are "equal to" their contents, as you might with a procedural language, you specify each property and its value or content using a colon (:).

Here's an example of a typical JavaFX Script code element: in this case, a clause that represents the placement of a Frame control, along with its default parameters, inside a JavaFX application's window. It's an excerpt from a tutorial article by Anghel Leonard, published last year by O'Reilly:

Frame {
 centerOnScreen: true
 visible: true
 height: 230
 width: 300
 title: "Capture the screen..."
 onClose: operation() {System.exit(0);}
 content: ScrollPane {
 background: white
 view: Canvas {
 background: black
 cursor: DEFAULT
 content: CaptureExample

It is not at all difficult to understand; what may become a little precarious for many new developers will be adjusting to all the new habits, and the new way of working. Contrast this method of development against Microsoft's, in which you would develop a control using a graphical environment, but the product is a graphics resource file using that company's XML scheme called XAML.

JavaFX utilizes the new NetBeans 6.5 IDE, which is now especially geared for Java and JavaFX. As with all its developer tools, the only investment Sun asks of you is your time and patience.

© 1998-2014 BetaNews, Inc. All Rights Reserved. Privacy Policy.