Hacking JavaFX 1.0 to use Java 1.6 Features

2 01 2009

Mark Chance was the first lucky user of JFXtras who ran into the JRE version issue when compiling the code. He had installed the latest version of Netbeans and configured a 1.6 JavaFX library, but was still getting “object not found” exceptions on 1.6-only classes. What was he doing wrong?

It turns out that the JavaFX 1.0 SDK ships with a slimmed down copy of rt15.jar in the lib/desktop folder, which ends up in the javafxpackager’s classpath for code compilation. This doesn’t have any of the new classes introduced in 1.6 such as SwingWorker, SystemTray, or even String.isEmpty(). However, if you plan to take advantage of any of the cool features of Java 1.6 like transparency or shaped windows, chances are that you require Java SE 6 anyway.

Here is how you hack the JavaFX 1.0 SDK to build against Java 1.6:

  1. Go to the installation directory of your 1.6 JRE and copy lib/rt.jar
  2. Find your JavaFX SDK installation directory and go to lib/desktop
  3. Delete or rename the existing rt15.jar file
  4. Paste the 1.6 rt.jar from step 1 into this folder, renaming it to rt15.jar

And that is it, you can now compile Java and JavaFX code with the javafxpackager that depends on 1.6-only features!

One important note for NetBeans users: Make sure to also update the rt15.jar in the JavaFX installation that comes bundled with NetBeans 6.5. If you forgot to do this, any projects that use the default JavaFX SDK will fail to compile.




14 responses

2 01 2009
Mark Chance

Thanks for figuring this out Steve. I had seen the rt15.jar and was suspicious, but didn’t follow that trail. Turns out, for us lucky Mac OSX users, “the rt.jar from your 1.6 JRE installation” is a bit more complicated.
I couldn’t find an rt.jar file 😦
So, I combined (from …/Versions/1.6.0) Classes/classes.jar and Home/
lib/dt.jar into a new rt15.jar. Can’t guarantee it has all the classes,
but has enough to get by for the moment…

16 12 2009
Eric Wendelin

Thanks for the Mac advice, Mark! Works like a charm 🙂

2 01 2009
Mark Chance

So one other thing was required to build… for some reason the JavaFx Scenario.jar file is not included in the classpath. Without it, “import com.sun.scenario.scenegraph.JSGPanel;” is not found. In my NetBeans project, I just added it to the required libraries. It’s not clear what the right fix is… I looked javafxpackager and javafxc scripts, but no list of jars is there…

2 01 2009

I’ve updated the project file to use the Scenario.jar file that Dean checked in under lib. Please sync up and give it another try!

9 01 2009

This seems to work too…

1. Add the following to your “.bash_profile”:

export JAVA_HOME
export PATH

2. Open/Restart Terminal

3. Executing “javafx -version” should yield:
java version “1.6.0_07”
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)

19 01 2009
Maya Incaand


I came here via James Weaver blog/calculator example.

Does this JFXtras still work with latest JavaFX updates?

I have problem to compile.

19 01 2009


Yes, it should work on the latest JavaFX version.

If you are trying to build JFXtras from source, I just posted a guide on the project wiki:

For more help, please post a message to the JFXtras Users mailing list:

19 01 2009
Maya Incaand


OK I went to the Wiki.

Think I will have easier time if I can download as an nbproject.

When I download and extract the zip, it is not recognized as an nbproject.

I see on the developers page that someone else with same problem.

Is there some other place to download?

19 01 2009
Maya Incaand

OK I see I have to use a subversion client to get the whole thing.

I will download a client and try that.

19 01 2009
Maya Incaand

OK I managed to get subversion running and checkout the whole thing, which solved my problem.


25 02 2009
kampanye damai pemilu Indonesia 2009

nice post, Thank for this reference

27 03 2009
John Dunning

Just got it working on a Mac and it turned out to be very easy.

cd /System/Library/Frameworks/JavaVM.framework/Versions

rm -f CurrentJDK (this is just a symlink to version you are using)

ln -s 1.6 CurrentJDK

11 07 2009
Eric Wendelin

Just curious. Has anyone tried deploying an application using this? Does it break JavaFX apps on Mac or even work on non-hacked systems?

11 07 2009

The WidgetFX application uses this, because it requires 1.6 features such as the System Tray. As long as you change the JNLP file to require Java 1.6 instead, it should work on all systems where the correct Java version is available.

The only exception is non-Intel 64 Mac OS X systems that don’t support Java 1.6. While this is unfortunate, Apple has left these systems on an architectural dead-end by no longer supporting the latest OS X version.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: