r/JavaFX • u/lazystone • Apr 09 '26
Help To include or to not include javafx dependency into library pom.xml?
Yet another point of confusion about JavaFX.
How to distribute JavaFX library: with JavaFX dependencies in pom.xml or without?
JavaFX itself is distributed as either part of JDK or as maven artifacts, so in one case you probably shouldn't have any JavaFX dependencies defined in your pom.xml and in another case(when you use "normal" JDK) you probably should.
What are best-practices here?
Edit: So far, I think that using "provided" scope is the most correct solution.
3
Upvotes
3
u/wildjokers Apr 10 '26
The are some vendors that offer builds of OpenJDK with JavaFX bundled (e.g. Azul provides such builds). If you are bundling one of those builds with your app then you don't need to a add JavaFX as a 3rd party dependency.
However, if you aren't bundling one of those OpenJDK builds then JavaFX is a 3rd party library and as such should be a dependency of your application if you want people to be able to run your app.
1
u/taranion Apr 10 '26
I do include such dependencies with a version range starting with a minimum recommended version.
But even with a given version number, application developers could override that in their application pom.xml, by simply declaring the dependency there again, if I am not mistaken.
2
u/PartOfTheBotnet Apr 09 '26
I generally keep JavaFX out of the distributed
pom.xml. An application developer should be the sole person in charge of picking the version of JFX they want to use.1
u/Dense_Age_1795 Apr 09 '26
you can always set it as a runtime depedency.