JavaFX 1.2: An introduction for developers

Post to Twitter

As a developer I’m starting to become somewhat picky with the technologies I spend my time to learn since there are so many “pet” programming languages, new toolkits, new frameworks, etc. JavaFX launched approximately a year ago. I’ve already got a pretty good grasp on Adobe’s Flash/Flex tools as well as a working knowledge of Microsoft’s Silverlight. I have limited time in how much I can digest new technologies so I don’t like to spend my time with something I won’t potentially use. With that said I’ve recently taken a look at JavaFX to see what it might offer.

With Larry Ellison’s recent comments about JavaFX at the JavaOne 2009 conference I began to ponder where this might lead. I also seen an intriguing new tool showcased at JavaOne 2009 – go ahead and watch those two videos, its well worth it if your interested in JavaFX. It kinda reminds me of the Flash Pro tool to some degree.

JavaFX Install Screen
(the JavaFX install screen)

A JavaFX sample application
(a JavaFX sample application)

Getting your development environment up and running is pretty easy, I’d even wager its easier/faster then getting a Silverlight development environment up and running (well, at least until Visual Studio 2010 ships perhaps). Going to the main JavaFX site you can quickly navigate to the section to install the tools which as of this writing is Netbeans 6.51 and the JavaFX SDK. For Windows its as easy as downloading and running the installer. I installed mine on a clean WindowsXP Virtual PC image with a gig of ram allocated and had no issues installing or running it. Keep in mind you can develop for JavaFX via the command line as well as the Eclipse plug-in.

My first tutorial was the “Getting Started With JavaFX Technology” which can be found here. Its more than just a “Hello World” introduction which is kinda refreshing sometimes although I’m famous for doing “Hello World” samples :-) The tutorial does a good job of showing off some of the power JavaFX holds.

JavaFX Development

I ran into no problems with the code or tutorial and had it coded and running in about 10 minutes. My only gripe is the the placement of the braces (perhaps this can be changed but I couldn’t find a way). I like my braces formatted like this:

function()
{
}

Not like this (the default right now for Netbeans/JavaFX):

function() {
}

Overall though I enjoyed the experience of going through this tutorial (and others) and I liked the ability to drag off items from the palette and drop them into the code. It greatly sped up my time creating the tutorial projects and it of course ensured I had the syntax correct as well as the capitalization.

JavaFX Palette

For developers wanting to simply go for the code samples in working projects rather than working through the numerous JavaFX tutorials there is the option to go into Netbeans and select: File -> New Project and then navigate to the Samples folder and then into the JavaFX folder. Here you’ll find a good number of samples that go from beginner to more advanced levels.

JavaFX Samples

Also keep in mind there are several good screencasts if you prefer that method to learn new technologies. Overall I’m impressed with the amount and quality of tutorials/documentation for JavaFX, its one of the better documented developer technologies out there with no lack of tutorials.

Now here’s the catch for developers that might already know Java and suddenly are working their way through say the “Learning the JavaFX Script Programming Language – Tutorial Overview“. Did you catch that? JavaFX S-C-R-I-P-T. You don’t use the Java language with JavaFX, you use JavaFX Script. If your familiar with Java, JavaScript or ActionScript I think you will be able to pickup Java FX Script pretty fast. Also, JavaFX script is compiled, not interpreted and of course it runs on the JVM compiled into Java bytecode just like Java, Groovy, and Scala. Your javaFX source file extensions end with “.jx” rather than “.java”.

JavaFX’s niche might just end up being putting RIA front ends on existing or new Java back end systems. I don’t know of course, but it seems like that is a good fit for it and its UI capabilities.

Something I’ve noticed is when I run the JavaFX samples they seem to take longer than comparable Flash/Flex samples to load and run. Of course I’m not totally comparing apples to apples here so this is just my two cents worth, but see for yourself:
1. Click me for Flash
2. Click me for JavaFX
(make sure you have the Flash Player and JavaFX loaded before doing the comparison)
Again, running the JavaFX samples it seems like there is a longer load time. Once they are running though they ran smooth.

Waiting for JavaFX to load
(What you see while waiting for JavaFX to load)

In their FAQ as well as here there is information on how to speed up JavaFX’s load time (I haven’t tried it yet though).

8.1 How do I make a JavaFX application start up faster?

Add the following line to the JNLP file:

<jnlp>
<update check="background"/>
</jnlp>

Then there is a section on all kinds of things you can do to improve the performance of your JavaFX application.

If I’ve piqued your interest in JavaFX then stay tuned to this blog because I will be putting up some more articles/tutorials on it in the future. I definitely had a much more pleasant experience with JavaFX than I was expecting, that said though I have to wonder where JavaFX will find it’s market? Its coming late to the market compared to Flash and even Silverlight but then again it seems to have a thriving community and above all some excellent documentation and of course free tools. I’ll be curious to see how well JavaFX is adopted not just by developers but end users and companies as well.

Some additional information about JavaFX:

– Like Adobe AIR and Silverlight 3 you can also run JavaFX apps outside of the browser via Java Webstart.

– Don’t under estimate the large amount of training material offered for learning JavaFX.

– Want a feature or found a bug? Submit it.

– Web Services are pretty easy.

– There are three books available for JavaFX now (as of this article’s publication date)
1. JavaFX: Developing Rich Internet Applications (Java Series)
2. JavaFX Script: Dynamic Java Scripting for Rich Internet/Client-side Applications
3. Essential JavaFX

– There are several more available soon’ish.

JavaFX Mobile, yes, there is a Mobile version.

– There are some free graphical tools to use with JavaFX called the: JavaFX 1.2 Production Suite

Post to Twitter

This entry was posted in Java, JavaFX. Bookmark the permalink.

3 Responses to JavaFX 1.2: An introduction for developers

  1. rawthinktank says:

    you forgot to tell why use JavaFx over GWT

  2. Chad Lung says:

    @rawthinktank,

    Depends on your product and audience. With JavaFX you are dependent on a runtime being installed on the end user’s computer whereas with GWT you only need to know they have a browser with JavaScript enabled. If I wanted to do complex animations , etc. I would pick something like JavaFX, Silverlight, or Flash.

    There are many factors. If I worked in a Java shop and had experienced Java developers on staff it seems to make more sense to pick JavaFX. If its a Flash/Flex shop then the Flash Player, etc.

    Chad

  3. Pingback: Gooder Code

Comments are closed.