'JavaFX give error after requires in pom file using maven
I'm currently creating project with blocks that can be connected (like blender or UE). And I found github project (VWorkflows) that I connected using its tutorial (in README). I add dependencies (core and fx). You can find my code here. I use IntelliJ as IDLE. First I add dependencies to pom.xml.
<dependency>
<groupId>eu.mihosoft.vrl.workflow</groupId>
<artifactId>vworkflows-core</artifactId>
<version>0.2.5.0</version>
</dependency>
<dependency>
<groupId>eu.mihosoft.vrl.workflow</groupId>
<artifactId>vworkflows-fx</artifactId>
<version>0.2.5.0</version>
</dependency>
After that code is still working. Then I add requires in the module-info.java
requires vworkflows.core;
requires vworkflows.fx;
And after that I got long error:
"C:\Program Files\Java\jdk-17\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\lib\idea_rt.jar=57204:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Ярослав\.m2\repository\org\openjfx\javafx-controls\17.0.0.1\javafx-controls-17.0.0.1.jar;C:\Users\Ярослав\.m2\repository\org\openjfx\javafx-graphics\17.0.0.1\javafx-graphics-17.0.0.1.jar;C:\Users\Ярослав\.m2\repository\org\openjfx\javafx-base\17.0.0.1\javafx-base-17.0.0.1.jar;C:\Users\Ярослав\.m2\repository\org\openjfx\javafx-fxml\17.0.0.1\javafx-fxml-17.0.0.1.jar;C:\Users\Ярослав\.m2\repository\org\jetbrains\annotations\23.0.0\annotations-23.0.0.jar;C:\Users\Ярослав\.m2\repository\net\sf\jung\jung-api\2.1.1\jung-api-2.1.1.jar;C:\Users\Ярослав\.m2\repository\com\google\guava\guava\19.0\guava-19.0.jar;C:\Users\Ярослав\.m2\repository\net\sf\jung\jung-graph-impl\2.1.1\jung-graph-impl-2.1.1.jar;C:\Users\Ярослав\.m2\repository\net\sf\jung\jung-algorithms\2.1.1\jung-algorithms-2.1.1.jar;C:\Users\Ярослав\.m2\repository\net\sf\jung\jung-visualization\2.1.1\jung-visualization-2.1.1.jar;C:\Users\Ярослав\.m2\repository\com\thoughtworks\xstream\xstream\1.4.11.1\xstream-1.4.11.1.jar;C:\Users\Ярослав\.m2\repository\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;C:\Users\Ярослав\.m2\repository\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar;C:\Users\Ярослав\.m2\repository\colt\colt\1.2.0\colt-1.2.0.jar;C:\Users\Ярослав\.m2\repository\concurrent\concurrent\1.3.4\concurrent-1.3.4.jar;C:\Users\Ярослав\.m2\repository\org\apache\commons\commons-collections4\4.4\commons-collections4-4.4.jar;C:\Users\Ярослав\.m2\repository\org\apache\commons\commons-math3\3.6.1\commons-math3-3.6.1.jar;C:\Users\Ярослав\.m2\repository\eu\mihosoft\jfx\scaledfx\scaledfx\0.4\scaledfx-0.4.jar -p C:\Users\Ярослав\IdeaProjects\LearningFX\target\classes;C:\Users\Ярослав\.m2\repository\eu\mihosoft\vrl\workflow\vworkflows-fx\0.2.5.0\vworkflows-fx-0.2.5.0.jar;C:\Users\Ярослав\.m2\repository\org\openjfx\javafx-graphics\15\javafx-graphics-15-win.jar;C:\Users\Ярослав\.m2\repository\org\openjfx\javafx-controls\17.0.0.1\javafx-controls-17.0.0.1-win.jar;C:\Users\Ярослав\.m2\repository\eu\mihosoft\vrl\workflow\vworkflows-core\0.2.5.0\vworkflows-core-0.2.5.0.jar;C:\Users\Ярослав\.m2\repository\org\openjfx\javafx-base\15\javafx-base-15-win.jar;C:\Users\Ярослав\.m2\repository\org\openjfx\javafx-fxml\17.0.0.1\javafx-fxml-17.0.0.1-win.jar -m com.example.learningfx/com.example.learningfx.HelloApplication
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: javafx.fxml.LoadException:
/C:/Users/Ярослав/IdeaProjects/LearningFX/target/classes/com/example/learningfx/hello-view.fxml:21
at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2685)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
at com.example.learningfx/com.example.learningfx.HelloApplication.start(HelloApplication.java:14)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make void com.example.learningfx.HelloController.initialize() accessible: module com.example.learningfx does not "opens com.example.learningfx" to module javafx.fxml
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at javafx.fxml/javafx.fxml.FXMLLoader$ControllerAccessor.addAccessibleMethods(FXMLLoader.java:3611)
at javafx.fxml/javafx.fxml.FXMLLoader$ControllerAccessor$1.run(FXMLLoader.java:3543)
at javafx.fxml/javafx.fxml.FXMLLoader$ControllerAccessor$1.run(FXMLLoader.java:3536)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at javafx.fxml/javafx.fxml.FXMLLoader$ControllerAccessor.addAccessibleMembers(FXMLLoader.java:3535)
at javafx.fxml/javafx.fxml.FXMLLoader$ControllerAccessor.getControllerMethods(FXMLLoader.java:3494)
at javafx.fxml/javafx.fxml.FXMLLoader$Element.getControllerMethodHandle(FXMLLoader.java:573)
at javafx.fxml/javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:610)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:781)
at javafx.fxml/javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2924)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2639)
... 12 more
Exception running application com.example.learningfx.HelloApplication
Process finished with exit code 1
I think I made everything by vworkflow tutorial but maybe someone can help?
Solution 1:[1]
Add the following line to file module-info.java: opens <package>
.
Where "" is your folder with java files. (src/java/folder).
Answer not my but from comment
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |