I try to run and my application with InteliJ and Maven on a Win 10 machine. If i run
mvn clean javafx:run
My GUI starts but if i use a Textfield from org.controlsfx.control.textfield.TextFields i encounter a problem
Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in unnamed module @0x19b440d0) cannot access class com.sun.javafx.event.EventHandlerManager (in module javafx.base) because module javafx.base does not export com.sun.javafx.event to unnamed module @0x19b440d0
i found that this is a know problem and that you have to pass to JVM following command.
--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls
But how i do this in maven? i tried 2 ways.
Way 1: using the .mvn/jvm.config file and add this command but this doesn't change anything at all even if a enter sensless stuff in there.
Way 2: adding a systemvariable MAVEN_OPTS with the --add-export command. Then maven reacts on this change but say:
WARNING: Unknown module: org.controlsfx.controls specified to --add-exports
How i can fix this?
edit: Way 3: according to https://github.com/openjfx/javafx-maven-plugin it should be possible to add to javafx-maven-plugin this --add-export to but InteliJ mark this as invalid that this element can not be used in this place
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.4</version>
<configuration>
<compilerArgs>
<arg>--add-exports</arg>
<arg>javafx.graphics/com.sun.glass.ui=org.openjfx.hellofx</arg>
</compilerArgs>
<mainClass>org.openjfx.hellofx/org.openjfx.App</mainClass>
</configuration>
</plugin>
https://github.com/openjfx/javafx-maven-plugin/issues/53 seems to be known but not considered as issue
For whoever finds this issue, javaFX plugin does no longer support the compiler options as described in way 3.
You will have to add the args to your compiler plugin like so:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerArgs>
<arg>--add-exports</arg>
<arg>java.management/sun.management=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With