Intellij Idea controls-fx,fx的运行时间错误:未知模块:org.controlsfx.controls指定到--add-exports

htrmnn0y  于 2023-10-15  发布在  其他
关注(0)|答案(1)|浏览(196)

我可以将controlsfx包含到我的IntelliJ项目中,但我无法运行该程序。我也尝试了另一种解决方案:将其添加到VM选项中

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

当我运行程序时,它有运行时错误:

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.
inkz8wg9

inkz8wg91#

看起来org.controlsfx.controls被IntelliJ放在类路径而不是模块路径上:

class org.controlsfx.control.textfield.AutoCompletionBinding (in unnamed module @0x6bbb636e)

(The未命名的模块表示类路径)。
IntelliJ根据项目本身是否是模块化的,将依赖项放在类或模块路径上。因此,为了让IJ将org.controlsfx.controls放在模块路径上,您必须通过添加module-info.java文件来模块化项目。
(see也就是:IntelliJ: Put some dependencies on the module path in non-modular application
如果你不想模块化你的项目,或者你可以尝试使用:

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

它将包导出到类路径(未命名的模块)。但是,如果org.controlsfx.controls不支持放在类路径上,这可能不起作用。

相关问题