0

This demo program illustrates a problem I have found when using Maven to compile the application using Java JDK 17 and JavaFX 17. I'm using Maven 3.8.1.

If I compile the application in a terminal with Maven, then these errors (excerpt) are produced:

% mvn clean compile
...
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ hellomvn ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/due1/workspace-tmp/btx.prog.one.hellomvn/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /path_to/btx.prog.one.hellomvn/src/main/java/btx/prog/one/hellomvn/App.java:[6,26] package javafx.application does not exist
[ERROR] /path_to/btx.prog.one.hellomvn/src/main/java/btx/prog/one/hellomvn/App.java:[7,20] package javafx.scene does not exist
...

However, if imported into Eclipse 2021-09 (with Java 17 Support Feature) or IntelliJ, then the application compiles and can be executed.

If I change the JavaFX version in the POM from 17 to 16, then Maven compiles the application:

        <java.version>17</java.version>
        <javafx.version>16</javafx.version>

Using mvn -U clean compile does not help either. I noticed when using Maven's (big-) -X option that with JavaFX 17, the JAR's of JavaFX are not on the classpath, but on the module-path only, whereas when specifying JavaFX 16, the JAR's of JavaFX 16 are on both, the classpath and module-path.

Any clue?

The complete program can be found here:

https://gitlab.com/edubuis/btx.prog.one.hellomvn

Eric D.
  • 31
  • 4
  • 3
    17 is broken in Maven, try [17.0.0.1](https://mvnrepository.com/artifact/org.openjfx/javafx-fxml/17.0.0.1). – jewelsea Sep 24 '21 at 07:22
  • I think this is related to this question: https://stackoverflow.com/questions/69116905/intellij-doesnt-load-javafx-packages-from-maven-dependencies. jewelsea answered it ("use JavaFX 16 until further notice"). Thanks. – Eric D. Sep 24 '21 at 13:24
  • 1
    I updated the recommendation in the linked duplicate from recommending to downgrade to version 16, to, instead, use version 17.0.0.1, as that now fixes the maven packaging issue which caused this error for the initial release of version 17 of the JavaFX 17 maven modules. – jewelsea Sep 24 '21 at 16:17
  • Thank you, jewelsea, for this solution. It works! – Eric D. Sep 27 '21 at 06:17

0 Answers0