Steve On Java

Hacking Java, JavaFX, and Flash with Agility
  • rss
  • Home
  • NightHacking Tour
    • [Archive] NightHacking Europe – The Road to Devoxx
  • SvJugFX
  • JFXtras
    • JFXtras Individual CLA
    • JFXtras Corporate CLA
  • 2013 Travel Map
    • Let’s Meetup!
    • 2012 Travel Map
  • Contact

Hacking JavaFX 1.0 to use Java 1.6 Features

steveonjava | January 2, 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.

 

Share this:

  • Twitter
  • Google +1
  • More
  • Facebook
  • LinkedIn
  • Email
Categories
JavaFX
Comments rss
Comments rss
Trackback
Trackback

« JFXtras 0.1 Release – Grids, Dialogs, Testing, and more! WidgetFX 1.0 Release »

19 Responses to “Hacking JavaFX 1.0 to use Java 1.6 Features”

  1. Mark Chance says:
    January 2, 2009 at 6:26 am

    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…

    Reply
  2. Mark Chance says:
    January 2, 2009 at 9:25 am

    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…

    Reply
  3. steveonjava says:
    January 2, 2009 at 11:46 am

    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!

    Reply
  4. alopecoid says:
    January 9, 2009 at 7:21 pm

    This seems to work too…

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

    JAVA_HOME=”/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home”
    export JAVA_HOME
    PATH=”${JAVA_HOME}/bin:${PATH}”
    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)

    Reply
  5. Maya Incaand says:
    January 19, 2009 at 5:39 am

    Hi

    I came here via James Weaver blog/calculator example.

    Does this JFXtras still work with latest JavaFX updates?

    I have problem to compile.

    Reply
  6. steveonjava says:
    January 19, 2009 at 5:57 am

    Maya,

    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:
    http://code.google.com/p/jfxtras/wiki/ContributorGettingStarted

    For more help, please post a message to the JFXtras Users mailing list:
    http://groups.google.com/group/jfxtras-users

    Reply
  7. Maya Incaand says:
    January 19, 2009 at 6:20 am

    Steve

    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?

    Reply
  8. Maya Incaand says:
    January 19, 2009 at 6:49 am

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

    I will download a client and try that.

    Reply
  9. Maya Incaand says:
    January 19, 2009 at 10:54 am

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

    Thanks.

    Reply
  10. kampanye damai pemilu Indonesia 2009 says:
    February 25, 2009 at 11:43 am

    nice post, Thank for this reference

    Reply
  11. John Dunning says:
    March 27, 2009 at 12:31 am

    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

    Reply
  12. Eric Wendelin says:
    July 11, 2009 at 8:46 am

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

    Reply
  13. Steve On Java » Launching Hyperlinks from JavaFX (including Mobile) says:
    March 4, 2010 at 11:52 am

    [...] hack is to modify your JavaFX distribution to include the rt.jar from Java 1.6 as explained in this earlier post.  The only problem with this is you also have to get all the other developers on your project to [...]

    Reply
  14. kailash says:
    August 5, 2010 at 9:54 am

    I want to get some information. i want to know system to hack. please sir help me for genrate this code/

    Reply
    • steveonjava says:
      August 5, 2010 at 10:08 am

      Please include more details about what you are doing so I can help out.

      Reply
  15. Stephen Meyer says:
    October 5, 2010 at 6:30 am

    thanks for the help on this Steve!
    on window 7 64bit i had one more step:
    update the rt15.jar in C:\Users\username\.netbeans\6.9\javafx-sdk\lib\desktop\ to the newer version

    Reply
  16. pearl says:
    April 29, 2011 at 3:50 am

    hey can anybody help……
    i just downloaded java 1.6 on windows xp 32bit………
    i tried alot but its not working……… :(

    Reply
  17. steveonjava says:
    July 11, 2009 at 11:49 am

    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.

    Reply
  18. Eric Wendelin says:
    December 16, 2009 at 10:15 pm

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

    Reply

Leave a Reply

Click here to cancel reply.

  • Travel Map - Let's Meetup

Publications

  

Affiliations

Awards

2009/2011 JavaOne Rock Star!

Disclaimer

Views and opinions expressed here are all my fault... complain to me, not my employer. :)
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.