Remove JavaFX JPMS enforcement

Michael Paus mp at jugs.org
Sat Apr 18 10:01:07 UTC 2020


Getting started with JavaFX is made overly complicated by the fact that 
the use of the
module system is enforced by some code in the JDK. Especially for 
beginners, who just
want to get some small program running, this is almost always a big 
source of frustration.
It is not very good marketing for JavaFX to make these initial steps 
such a pain. If you
need some evidence for this statement, then just follow JavaFX on 
Stackoverflow or similar
sites (and also this mailing list). Almost every day you can read 
frustrated posts from
helpless people who would just like to get some JavaFX project running 
but are failing
because they get lost in the module system jungle.

In order to make JavaFX more easily accessible, especially for 
beginners, I'd like to start
a discussion here about the possibility to unconditionally remove the 
JavaFX JPMS
enforcement. IMHO this enforcement is simply not necessary and is just 
the root for a lot
of frustration with JavaFX. It should just be possible to put all the 
JavaFX jars on the
classpath (instead of the module path) like you would do with any other 
external dependency
in a non-modular setup.

With a not very intuitive hack you can circumvent this problem already now.
Just add a line like this to the file which contains your main class 
extending
Application (MyApp).

class MyAppLauncher {public static void main(String[] args) 
{MyApp.main(args);}}

Because of this launcher it is now possible to put all dependencies and 
all JavaFX jars
on the classpath and to completely forget the module system with all its 
intricacies and pitfalls.
But why should people be forced to use such dirty tricks? The better 
alternative would be to just
lift the current constraint.

I am using this trick for a long time now, even on bigger projects, and 
I have never ever
experienced any problem resulting from this. Even in theory I don't know 
anything that
could prevent a formally correct module jar to also work on the 
classpath (which is of
course not true the other way round). Therefore I say that this 
constraint is just not
necessary and only does a lot of damage to JavaFXs reputation.

I'd now like to have some feedback of the community about this.

Michael




More information about the openjfx-dev mailing list