创建MediaView时发生IllegalAccessError

时间:2019-09-19 08:42:55

标签: java javafx

我尝试在JavaFX中创建的现有UI中实现MediaView。我所有其他代码都可以在不同的PaneLabelImageViewButton中正常工作。当我尝试添加MediaView时,我得到:

Caused by: java.lang.IllegalAccessError: superclass access check failed: class javafx.scene.media.NGMediaView (in unnamed module @0x6f0df6bf) cannot access class com.sun.javafx.sg.prism.NGNode (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.sg.prism to unnamed module @0x6f0df6bf

我尝试将jdk&jfx切换到最新版本(13),但没有帮助。 我尝试用--add-module添加模块,但在不同版本中均不起作用。

Pane p= (Pane) scene1.lookup("#media_pane");
MediaView mv=new MediaView();
mv.setFitWidth(300);
mv.setFitHeight(300);
p.getChildren().add(mv);
"C:\Program Files\Java\jdk-13\bin\java.exe" --module-path "C:/Program Files/Java/javafx-sdk-13/lib" --add-modules javafx.controls,javafx.fxml,javafx.graphics --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED -Djava.library.path=C:\Germaneers\JavaWorkspace\19-AU-EE74-001-Kombianzeige-im-Schwarzdruck-App\lib "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.2\lib\idea_rt.jar=58845:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Germaneers\JavaWorkspace\19-AU-EE74-001-Kombianzeige-im-Schwarzdruck-App\out\production\19-AU-EE74-001-Kombianzeige-im-Schwarzdruck-App;C:\Program Files\Java\javafx-sdk-13\lib\javafx-swt.jar;C:\Program Files\Java\javafx-sdk-13\lib\javafx.base.jar;C:\Program Files\Java\javafx-sdk-13\lib\javafx.controls.jar;C:\Program Files\Java\javafx-sdk-13\lib\javafx.fxml.jar;C:\Program Files\Java\javafx-sdk-13\lib\javafx.graphics.jar;C:\Program Files\Java\javafx-sdk-13\lib\javafx.media.jar;C:\Program Files\Java\javafx-sdk-13\lib\javafx.swing.jar;C:\Program Files\Java\javafx-sdk-13\lib\javafx.web.jar;C:\Germaneers\JavaWorkspace\19-AU-EE74-001-Kombianzeige-im-Schwarzdruck-App\lib\kotlin-stdlib.jar;C:\Germaneers\JavaWorkspace\19-AU-EE74-001-Kombianzeige-im-Schwarzdruck-App\lib\kotlin-reflect.jar;C:\Germaneers\JavaWorkspace\19-AU-EE74-001-Kombianzeige-im-Schwarzdruck-App\lib\kotlin-test.jar;C:\Germaneers\JavaWorkspace\19-AU-EE74-001-Kombianzeige-im-Schwarzdruck-App\lib\kotlin-stdlib-jdk7.jar;C:\Germaneers\JavaWorkspace\19-AU-EE74-001-Kombianzeige-im-Schwarzdruck-App\lib\kotlin-stdlib-jdk8.jar" main.Main
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:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    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:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
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:830)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class javafx.scene.media.NGMediaView (in unnamed module @0x6f0df6bf) cannot access class com.sun.javafx.sg.prism.NGNode (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.sg.prism to unnamed module @0x6f0df6bf
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:823)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:721)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:644)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at main.Main.initScene1(Main.java:62)
    at main.Main.start(Main.java:36)
    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:391)
    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
Exception running application main.Main

Process finished with exit code 1 

0 个答案:

没有答案