How are library developers supposed to specify JavaFX dependencies (on JFX/JDK >= 11)?

Johan Vos johan.vos at
Sun Feb 10 15:16:10 UTC 2019

Hi Michael,

You have to make a clear distinction between modules and jars.
Libraries should be one or more modules, and their dependencies should be
declared in a

There are no platform-dependent modules in JavaFX. If your library depends
on, you declare that in your You don't
declare any platform-specific things in the As such, the
"module" concept is close to the WORA concept of Java.

As a library developer, you leverage the public API's exposed by the JavaFX
modules. Those API's are platform-independent and well documented. Nice and

The jar-question is something completely different. Ideally, tools
(mvn/gradle) should be able to work well with modules, and integrate
platform-specific requests (e.g. I'm on linux, my project depends on module
fxyz, which depends on, now download the required jars and
put them on the modulepath).
Unfortunately, we're not there yet. We are in the awkward situation where
you have to duplicate dependencies from your into jar
dependencies a pom.xml. Since the JavaFX modules *contain* (not expose!)
platform-specific code (cleanly hidden from the end-user though, via the
module concept), this leads to the ugly situation where you have
platform-specific jars in a pom.xml. Maven deals with it pretty well, since
it works well with the classifier concept.
If you publish your library, you need to make sure you do not add a
classifier to the jar dependencies you put in a pom.xml. Your library does
not depend on a specific platform jar -- this is something that is dealt
with by the end-project.

The single most important thing is that you get your module dependencies
right. The second thing is that for now, you need to duplicate work by
providing similar dependencies in a pom.xml, and those should not have a

As for splitting the jars between a platform-specific jar and a generic
jar, I don't see a need for this. Libraries should write code against a
module, not against a jar.

- Johan

On Fri, Feb 8, 2019 at 11:57 PM Michael Hoffer <info at>

> Hi,
> first of all, thanks for moving JavaFX forward. I just tried to migrate
> some of my JavaFX libraries from JDK 8 to 11. The migration story is
> already great for application developers. Well done. However, the
> documentation seems to lack significant information for library developers.
> I ran into the following problem:
> How do I declare platform independent dependencies as a library developer?
> Currently, I am forced to specify the platform dependent version in my
> build script (be it explicit via `$platform` or implicit via the new JavaFX
> Gradle plugin). Am I right, that there's no real platform independent jar
> file + platform dependent jar? I only see merged jars where platform
> dependent Java code + platform dependent natives are mixed with platform
> independent Java code.
> But that would mean that a user of my library would need to specify the
> JavaFX dependencies in his/her project. But how do users know which
> platform-dependent modules to declare as dependency? That’s something we
> usually expect Maven/Gradle to handle for us.
> TL;DR:
> - What is the intended way for declaring JavaFX dependencies for third
> party JavaFX libraries (NOT apps) for JDK >=11
> - What’s the reason for not splitting the dependencies into platform
> dependent and platform independent parts as it is done by other Java
> libraries?
> Thanks,
> Michael
> --
> Dr. Michael Hoffer
> Web: <>
> Twitter: @mihosoft
> Goethe-Zentrum für Wissenschaftliches Rechnen (G-CSC)
> Goethe-Universität
> Kettenhofweg 139
> 60325 Frankfurt am Main
> phone: +49 69 798 25254 <+49%2069%2079825254>
> info at <mailto:info at>

More information about the openjfx-dev mailing list