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:
- Go to the installation directory of your 1.6 JRE and copy lib/rt.jar
- Find your JavaFX SDK installation directory and go to lib/desktop
- Delete or rename the existing rt15.jar file
- 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.