1

Yes, this question has been asked before, but none of the answers provided there solved the issue so:

I'm using ControlsFX 11 on a test project, every time I try to run the project I get this error:

Caused by: java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in module org.controlsfx.controls) cannot access class com.sun.javafx.event.EventHandlerManager (in module javafx.base) because module javafx.base does not export com.sun.javafx.event to module org.controlsfx.controls

I tried adding:

--add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls

And:

--add-exports javafx.base/com.sun.javafx.event=ALL-UNNAMED

Neither of them solved the issue. I'm using IntelliJ IDE and JDK 18.0. This is the full run:

D:\jdk18\bin\java.exe "-javaagent:D:\IntelliJ IDEA 2022.1\lib\idea_rt.jar=53684:D:\IntelliJ IDEA 2022.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-controls\18-ea+6\javafx-controls-18-ea+6.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-graphics\18-ea+6\javafx-graphics-18-ea+6.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-base\18-ea+6\javafx-base-18-ea+6.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-fxml\18-ea+6\javafx-fxml-18-ea+6.jar" -p "C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-fxml\18-ea+6\javafx-fxml-18-ea+6-win.jar;C:\Users\Windows 10\IdeaProjects\test32\controlsfx-11.1.0.jar;C:\Users\Windows 10\IdeaProjects\test32\target\classes;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-controls\18-ea+6\javafx-controls-18-ea+6-win.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-base\18-ea+6\javafx-base-18-ea+6-win.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-graphics\18-ea+6\javafx-graphics-18-ea+6-win.jar" -m com.example.test32/com.example.test32.HelloApplication --add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls
Exception in Application start method
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465)
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1081)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in module org.controlsfx.controls) cannot access class com.sun.javafx.event.EventHandlerManager (in module javafx.base) because module javafx.base does not export com.sun.javafx.event to module org.controlsfx.controls
    at org.controlsfx.controls/org.controlsfx.control.textfield.AutoCompletionBinding.<init>(AutoCompletionBinding.java:538)
    at org.controlsfx.controls/impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding.<init>(AutoCompletionTextFieldBinding.java:107)
    at org.controlsfx.controls/impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding.<init>(AutoCompletionTextFieldBinding.java:92)
    at org.controlsfx.controls/org.controlsfx.control.textfield.TextFields.bindAutoCompletion(TextFields.java:187)
    at org.controlsfx.controls/org.controlsfx.control.textfield.TextFields.bindAutoCompletion(TextFields.java:181)
    at com.example.test32/com.example.test32.HelloController.initialize(HelloController.java:25)
    at javafx.fxml@18-ea/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2655)
    at javafx.fxml@18-ea/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
    at javafx.fxml@18-ea/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
    at com.example.test32/com.example.test32.HelloApplication.start(HelloApplication.java:14)
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
    at javafx.graphics@18-ea/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
    at javafx.graphics@18-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.graphics@18-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    at javafx.graphics@18-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics@18-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics@18-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
    ... 1 more
Exception running application com.example.test32.HelloApplication

Process finished with exit code 1
Slaw
  • 37,820
  • 8
  • 53
  • 80
Skmp
  • 41
  • 1
  • 6
  • Perhaps you [set a program argument rather than a Vm argument](https://stackoverflow.com/questions/50938383/how-to-set-jvm-arguments-in-intellij-idea) – jewelsea May 15 '22 at 15:57
  • @jewelsea I added it as a VM, after your comment I double checked again to make sure and even tried both program arguments and VM options, neither worked – Skmp May 15 '22 at 16:04
  • 1
    I don't know if you changed things since @jewelsea commented, but the command line shown in your "full run" output has the `--add-exports` argument _after_ the `-m` (i.e., `--module`) argument. That means the `--add-exports` argument was set as an _application argument_ instead of a _VM argument_. – Slaw May 15 '22 at 17:39

0 Answers0