Wednesday, June 27, 2007

Minimal JavaFX Demo

Here are the absolute simplest steps to get a demo of JavaFX up an running:
  1. Download the 3 JavaFX jar files:


    You can get them from here:

  2. Create a text file called Hello.fx:
    import javafx.ui.*;
    Frame {
        content: Label {
            text: "Hello JavaFX"
        visible: true

  3. Add the 3 jars and Hello.fx to your classpath

  4. Run the script like so:

    java Hello

    Note: The name Hello is resolved via the classpath (not the file system).

    Here is how my folders looked:


    Thus, my classpath must include the classes folder plus the 3 jar files:


    Here is the shell script I used:

    java -classpath $cp Hello

    Note: The way I have the paths specified, you must run this script from within DavesJavafxDemo folder.

    On Windows, the shell script (runDemo.bat) would look like this:

    set cp=.\lib\swing-layout.jar;.\lib\Filter.jar;.\lib\javafxrt.jar;.\classes
    java -classpath %cp% Hello


Anonymous said...


I don't understand the goal of JavaFX. As a Flash alternative seems limited... JavaFX is not offered as a plug-in (as Flash), and I don't know if it can run as an applet.

On the other hand, how good it is for application development? I have a portal and I would love to put JavaFX on it, but I'm not sure if it would be better than using Flash-oriented tools, such as Laszlo.

Is there a place for JavaFX?


josh said...

This is cool stuff, Dave. I hope to make your talk tonight.

Anonymous said...

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!