Drombler FX: building modular JavaFX applications with OSGi and Maven

Florian Brunner fbrunnerlist at gmx.ch
Thu Dec 20 11:35:45 PST 2012

Hi Tom, hi Filipe,

Sorry, for the late answer. I somehow didn't get these e-mails, but I just found them in the Internet.

Yes, all you need to do to make the JavaFX classes accessible by OSGi is to specify "org.osgi.framework.system.packages.extra" and pass this information to org.osgi.framework.launch.FrameworkFactory.newFramework in your OSGi launcher.

You can find the relevant code in these projects:




Or in other words: since JavaFX is installed separately on the end user machines (as part of the JRE), we can access them as "system packages" (similar to all the other classes of the standard Java library) rather than wrapping JavaFX up somehow as a bundle (which we don't do for the other classes of the standard Java library either).

Note that even this shoudn't be necessary once JavaFX gets part of the standard JDK and your OSGi implementation specifies "org.osgi.framework.system.packages" accordingly.

The next step is to make sure JavaFX gets started properly.

For this you need the following Manifest entries in your main jar:

JavaFX-Application-Class: org.drombler.fx.startup.main.Main
JavaFX-Version: 2.0
Main-Class: com.javafx.main.Main

where org.drombler.fx.startup.main.Main is an OSGi launcher for JavaFX.

The drombler-fx-startup-main project mentioned above specifies the Manifest entries to be generated in the POM and the Drombler FX Maven Plugin adds the com.javafx.main.* classes to the final main jar (similar to what the Ant script provided by JavaFX is doing). The plugin also copies all direct and transitive dependencies with scope "compile" or "runtime" to the deployment directory.

Here is the relevant project:


Have a look at CreateStandaloneZipMojo.

So far no JavaFX class has been used (apart from com.javafx.main.Main specified the Manifest).

The next step is to call javafx.application.Application.launch.

Drombler FX does this in a simple OSGi bundle using OSGi Declarative Services (using Apache Felix SCR annotations).

Here is the relevant project:


Have a look at the following classes: FXApplicationLauncher and ModularApplication

Again, if you're using Drombler FX you will get all of this out-of-the-box and several extension points as well.

- Florian

> Hi tom,
> I follow your projects for long time, really like... i'm such a fan!!
> I created the moduleFX for the 2.1 JavaFX, and JDK version without
> preinstalled JavaFX, never tested for the newer versions... for sure I'll
> look at florian domblerFX to learn how to manage this problem!! Thanks for
> the tips!!
> On Thu, Dec 13, 2012 at 7:24 PM, Tom Schindl <tom.... at bestsolution.at>wrote:
> Hi Filipe,
> From code inspection I think Florians solution is the way to get JavaFX
> running in Felix because he's modifying
> "org.osgi.framework.system.packages.extra". If I'm not 100% mistaken your
> solution will hit what I describe at
> http://tomsondev.bestsolution.at/2012/08/01/javafx-2-2-and-osgi/ in the
> "Straight Repackageing" section.
> In short: If a user runs with your solution on a JDK which has JavaFX
> preinstalled the native code from the JDK will be picked up and the
> Java-Code from your module-fx and there are good chances that they don't
> match!
> If I got the solution from Florian right he's using
> org.osgi.framework.system.packages.extra to teach OSGi the new packages and
> somehow modifies the application classpath, or something similar.
> My Equinox solution on the other hand has the advantage that you don't have
> to control the bootstraping which is e.g. the case when you want to use
> JavaFX inside an Eclipse Plugin.
> Tom
> Am 13.12.12 18:00, schrieb Filipe Portes:
> Hi everyone,
> I create a simple project called ModuleFX that also make you capable of run
> JavaFX application over OSGI, It's still very simple, but if anyone get
> intersted here's the link: https://github.com/filipeportes/ModuleFX
> On Sun, Dec 9, 2012 at 11:09 AM, Florian Brunner <fbru... at gmx.ch wrote:
> Hi everybody,
> I'm happy to announce the availabilty of a first Early Access version of
> Drombler FX. Drombler FX is a modular Rich Client Platform for JavaFX.
> You can read more about it here: http://puces-
> blog.blogspot.ch/2012/12/drombler-fx-building-modular-javafx.html
> There's a Getting Started page which explains how to create, build and run a
> Drombler FX sample application with a few simple steps:
> http://wiki.drombler.org/GettingStarted
> - Florian
> -- B e s t S o l u t i o n . a t EDV Systemhaus GmbH
> ------------------------------------------------------------------------ tom
> schindl geschäftsführer/CEO
> ------------------------------------------------------------------------
> eduard-bodem-gasse 5-7/1 A-6020 innsbruck fax ++43 512 935833
> http://www.BestSolution.at phone ++43 512 935834
> -- Filipe Portes - @filipeportes Java Architect - Senior Java EE/Web
> JUGLeader Gojava <http://www.gojava.org/> - @gojava

More information about the openjfx-dev mailing list