I could include the controlsfx into my project in IntelliJ but I can't run the program. I also already try the other solution: adding this into VM options
--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls
When I run the program, it has run time error:
WARNING: Unknown module: org.controlsfx.controls specified to --add-exports
Caused by: 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:578)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:72)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at [email protected]/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:270)
at [email protected]/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)
at [email protected]/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1853)
... 33 more
Caused by: java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in unnamed module @0x6bbb636e) 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 @0x6bbb636e
at org.controlsfx.control.textfield.AutoCompletionBinding.<init>(AutoCompletionBinding.java:538)
at impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding.<init>(AutoCompletionTextFieldBinding.java:107)
at impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding.<init>(AutoCompletionTextFieldBinding.java:92)
at org.controlsfx.control.textfield.TextFields.bindAutoCompletion(TextFields.java:188)
at org.controlsfx.control.textfield.TextFields.bindAutoCompletion(TextFields.java:182)
at Controller.HomeSubScene.SearchBookingController.setUp(SearchBookingController.java:44)
at Controller.HomeCustController.showScene(HomeCustController.java:162)
at Controller.HomeCustController.showManageBookingScene(HomeCustController.java:134)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 40 more
I hope I could use the controls fx in my project.
It looks like
org.controlsfx.controlsis being put onto the class path instead of the module path by IntelliJ:(The unnamed modules means the class path).
IntelliJ puts dependencies on the class or module path depending on whether the project itself is modular. So, in order to have IJ put
org.controlsfx.controlson the module path, you have to modularise the project by adding amodule-info.javafile.(see also: IntelliJ: Put some dependencies on the module path in non-modular application)
If you don't want to modularise your project, alternatively you could try using:
Which exports the package to the class path instead (unnamed module). However, this might not work if
org.controlsfx.controlsdoes not support being put on the class path.Of course this is breaking the encapsulation fo the javafx.base module and exposing an internal implementation detail that is not part of the public API, and should rather not be depended upon. However, for migration to later versions of Java, the above flag can be used as a temporary solution.