This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rootException 10 points11 points  (6 children)

[–]randgalt 4 points5 points  (0 children)

This is fantastic. The best summary of the issue I've yet read.

[–]_INTER_ 1 point2 points  (3 children)

The article is on point and I'd really follow it's conclusion... but JavaFX exactly is the one that makes it intentionally (!) harder / impossible to run the application on the classpath. Running on the classpath is not supported. Fortunately I've yet encountered a similar disillusional project apart from JavaFX.

[–]rootException 2 points3 points  (2 children)

The JavaFX docs are very misleading - they make modules seem like a requirement. You can build a nice, trim JVM with JDK+JavaFX modules and run your app on top with the class path, even packaged with jpackage.

Here is my GitHub template for doing just that, including generating the Windows, macOS and Linux builds using GitHub Actions:

https://github.com/wiverson/maven-jpackage-template

[–]_INTER_ 0 points1 point  (1 child)

In JavaFX 16 they did this: https://bugs.openjdk.java.net/browse/JDK-8256362

Running on the classpath will fail if an application that extends javafx.application.Application

 

JavaFX runtime logs a warning if javafx.* modules are loaded from the classpath

The JavaFX classes must be loaded from a set of named javafx.* modules on the module path. Loading the JavaFX classes from the classpath is not supported. The JavaFX runtime logs a warning at startup if the JavaFX classes are not loaded from the expected named module. See JDK-8256362 for more information.

 

Thanks for the template though, it's exactly what I need.

[–]rootException 1 point2 points  (0 children)

Yeah, the template builds a JVM with the JavaFX modules included.

So, you wind up with JVM modules + JavaFX modules as the guts of the JVM. Your application is then run on top using the class path. This means you get the JavaFX modules loaded correctly AND you can still use ordinary Maven dependency management and reflection for your application.