How can I use JavaFX 2.2 in a OSGi bundle? I'm using Apache Felix so it's no eclispe project. It must run on Mac OSX with Java7 installed (Java6 would be cool but not necessary).
I've read something about repacking the jfx libraries but for eclispe plugin projects.
Just importing the javafx packages in the bundle Manifest created a missing requirement osgi.wiring.package Exception.
It's a little late to help you, probably, but I would like to document a straightforward way to enable JavaFX inside an OSGi environment in case anybody, like me, still had trouble doing it....
The thing is, you need to allow JavaFX the possibility to load and use any class it wants (JavaFX makes use of internals of the JRE which makes it really hard to bundle), so what you really want is to give it access to the OSGi boostraping classpath...
I'm no expert, but in this blog, Costin Leau, from SpringSource, explains how to do it (for any jars which assume full access to the system classloader, not only JavaFX) in 3 different ways:
http://blog.springsource.org/2009/01/19/exposing-the-boot-classpath-in-osgi/
I chose to use option A, which basically means setting the OSGi-specified property (not specific to any implementation!) in your OSGi container's config file:
org.osgi.framework.system.packages.extra=javafx.application;version=0.0.0 ...
You can see the whole value of the property in this Gist I've created:
https://gist.github.com/renatoathaydes/5021107
I basically set it with all of the packages which the JavaFX 2.2 jar can export (and I found this out by simply dropping the JavaFX jar into the deploy folder of my Apache Karaf, which automagically makes it into a bundle, and then looking at the generated Manifest)... by the way, I tried to use the bundle generated by Karaf (which uses pax-wrap to do it) but this won't work due to the way JavaFX tries to load your classes (which are not visible in the attempted JavaFX bundle, not to mention all the JRE packages JavaFX tries to access).
I suspect not all of the packages I added are actually required, but to be safe, I left them all as generated by Karaf's wrapper and as it works, I won't change that unless there's a good reason for that.
Now any of my bundles can use JavaFX as long as the jfxrt.jar is present in the JRE lib folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With