What Does JavaFX Mean For You?
What Does JavaFX Mean For You?
Join the DZone community and get the full member experience.Join For Free
There's a lot of hype, talk and tutorials going on around JavaFX. What I'd like to do in this article is to take a step back and discuss what JavaFX means for you (and me), the ordinary Java developer. With technologies like JavaFX, it's easy to get caught up in the details, but more difficult to work out if it's something that you really need to consider.
A Brief History
JavaFX is a rich client platform that allows you to create applications that will work across multiple devices. Currently, these devices include desktop and mobile targets. One of the key advantages to JavaFX is that the code you write for one of these devices will work on any other device. As JavaFX is integrated with the Java runtime, it will run on any desktop with Java installed, and will run on any phone that provides JavaME.
JavaFX was first announced by Sun at JavaONE 2007. Version 1.0 was released in December 2008, targetted at the desktop platform while 1.1 was released recently for mobile devices. To put it simply, JavaFX is Sun's competition to the two main RIA implementations available - Microsoft's SilverLight and Adobe's Flex/AIR.
Looking at the situation in greater detail, JavaFX's main strength comes for how it can interact with Java code, and Swing components. Some are sceptical of Sun's investment into JavaFX - thinking it would be better to invest more on Swing - but it certainly opens some more doors for Java developers. Already JavaFX has seen some very high download numbers - before version 1.1 was released the runtime was heading for over 80 million downloads.
What Can JavaFX Do That Swing Can't?
One of the really nice things in JavaFX is the ability to drag a JavaFX application from inside your web browser to the desktop. This in turn makes it easier to create applications like WidgetFX, which provides desktop widgets. Rich video content is made possible through the On2 video codecs which are supplied with JavaFX. It's worth noting that these same codecs can work in your Swing applications too.
JavaFX applications are written in JavaFX Script. The script takes advantage of a general scene graph model, that allows effects, transforms and animations in your UI. Using JavaFX Script you can put user interfaces together quickly, as the language is written specifically for user interface creation. The resulting applications have a richer, smoother feel than standard Swing applications.
A Place For JavaFX In The Technology Stack
The term Rich Internet Application can be defined as an web application that takes on the characteristics of a desktop application. When most people think of an RIA, they will think of Flash. Maybe it's just that we've blocked it all out from memory, but Java Applets provided us with the first real RIA. 10 years on, learning from the past, Sun have given a new way for Java developers onto the web.
So, where does writing applications in JavaFX make sense? The key use case for me, is for those who are starting an application from scratch. If it needs to interact with other Java components and libraries, JavaFX is a good choice for your UI layer. If you want to write an application to work on the desktop and on mobile devices, with minimal deployment headaches, this is the technology you need. The single-sourcing aspect of JavaFX is the main advantage.
Things get muddier when you are considering JavaFX for your current applications. As it stands now, there is no official way to get JavaFX embedded into your Swing (or SWT) application. There is a workaround available, I'm just not sure if I'd use that in applications that go out for production. From talking to the JavaFX team, it seems that this issue will be addressed in future releases. With a good architecture, and clean seperation of your UI layer, it should be possible to move your UI code to JavaFX.
For those writing for mobile devices, JavaFX gives much richer graphics and UI's than JavaME does. It's easier to code for mobile with JavaFX too, and easier to test, due to the same programming model being used for desktop and mobile.
In summary, if you're starting fresh, and want to have a user interface that is 'flashier' than what you can do right now with Swing, JavaFX is a good choice.
Where Can You Get It?
There are three different components to the JavaFX download. The SDK includes the JavaFX compiler, runtime tools and the various libraries for video, graphics and web services that are needed to create your applications for the mobile or desktop platforms.
There is also a Netbeans plugin available for JavaFX. The download site provides a link to download the complete Netbeans IDE (6.5) for JavaFX. This will help you create JavaFX applications even faster, and provides a mobile emulator so that you can preview you application for a mobile device.
Finally, the JavaFX 1.1 Production Suite is a suite of tools and plugins that enable designers to export graphical assets to JavaFX applications. This is probably of least interest to Java developers, and is aimed more at graphical designers.
For those who prefer to work with Eclipse, there is also a plugin available, allowing you to add a JavaFX nature to your project.
Writing JavaFX Applications
In terms of getting start with JavaFX scripting, the best place to go is to Netbeans and take a look at the sample projects there. A gallery of samples are also listed on the JavaFX.com site. Stephen Chin's WidgetFX project - a desktop widget platform written in JavaFX - is also a great example of what can be done with JavaFX. Stephen is writing a book with Jim Weaver at the moment, Pro JavaFX Platform which is in early access at the moment.
It's still early days for JavaFX. If you're looking for an alternative to Flash, and you are already familiar with Java, it's worth taking a look at. In the upcoming releases, I'm sure we'll start to see strong reasons to go with JavaFX as your UI technology for Java applications.
This is all just my own opinion however. I'm interested to hear what you think the the key points are that make JavaFX a good technology choice?
Opinions expressed by DZone contributors are their own.