superclass 访问检查失败:class com.sun.javafx.sg.prism.web.NGWebView
superclass access check failed: class com.sun.javafx.sg.prism.web.NGWebView
我刚刚安装了 SDK 11 并使用了来自 Maven 的 Javafx。我的pom如下。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.restfbui21feb</groupId>
<artifactId>uipostdownload</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>LATEST</version>
<configuration>
<mainClass>ui.postDisplayAndAction</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.restfb</groupId>
<artifactId>restfb</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
</dependency>
</dependencies>
</project>
我正在使用 WebView,它可以帮助我查看 Facebook 数据并下载我需要的任何内容。
请找出异常如下:
java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.sg.prism.web.NGWebView (in unnamed module @0x253d5cf1) cannot access class com.sun.javafx.sg.prism.NGGroup (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.sg.prism to unnamed module @0x253d5cf1
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:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at ui.PostDisplayandAction.<clinit>(PostDisplayandAction.java:37)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.loadClass(LauncherImpl.java:382)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs(LauncherImpl.java:421)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
我添加了以下虚拟机--module-path /Applications/javafx-sdk-11.0.2/lib --add-modules=javafx.controls,javafx.fxml,javafx.base
我似乎在过去 2 小时内一直在尝试让此代码正常工作。代码中没有编译错误。我犯了什么错误?
您必须添加 --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
,它应该可以工作!
在我的例子中,问题出现在从 jdk13 到 jdk14 之后。
所以你最好在你的编辑器上将它添加到你的虚拟机中:
--module-path /Applications/javafx-sdk-11.0.2/lib --add-modules=javafx.controls,javafx.fxml,javafx.base --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
或者用 --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
完成那里的内容
也许你可以检查这个问题https://github.com/GSI-CS-CO/chart-fx/issues/6
它帮我解决了这个问题
只需将此内容附加到您的配置中
--module-path /path/to/javafx-sdk-11.0.2/lib --add-modules=javafx.swing,javafx.graphics,javafx.fxml,javafx.media,javafx.web --add-reads javafx.graphics=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.charts=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.iio=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.iio.common=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED
也许有用
我只是将这一行添加到我的 VM 选项中,它就起作用了
--add-modules javafx.web
我在添加WebView时遇到了同样的问题。对我有用的是:
1- 通过转至 File/New/Module 从现有资源 ..
将您的项目变成模块化项目
2- 将“requires javafx.web”行添加到您的模块-info.java 文件中,如下所示:
module com.example.demo {
requires javafx.controls;
requires javafx.fxml;
requires javafx.web;
opens com.example.demo to javafx.fxml;
exports com.example.demo;
}
3- 将以下依赖项添加到您的 pom.xml 文件中:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>11.0.2</version>
</dependency>
3- 最后,我将 openJdk 更改为 Amazon Corretto JDK。还要考虑包含开箱即用的 JavaFX 的 Azul Zulu Jdk 版本(您甚至不需要在项目 pom 中包含 JavaFx 依赖项)
我通过进入 Run Configuration
-> VM arguments
并添加以下参数行来修复我的问题:
--add-modules=javafx.swing,javafx.graphics,javafx.fxml,javafx.media,javafx.web
--add-reads javafx.graphics=ALL-UNNAMED
--add-opens javafx.controls/com.sun.javafx.charts=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.iio=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.iio.common=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED
--add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED
我刚刚安装了 SDK 11 并使用了来自 Maven 的 Javafx。我的pom如下。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.restfbui21feb</groupId>
<artifactId>uipostdownload</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>LATEST</version>
<configuration>
<mainClass>ui.postDisplayAndAction</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.restfb</groupId>
<artifactId>restfb</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
</dependency>
</dependencies>
</project>
我正在使用 WebView,它可以帮助我查看 Facebook 数据并下载我需要的任何内容。
请找出异常如下:
java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.sg.prism.web.NGWebView (in unnamed module @0x253d5cf1) cannot access class com.sun.javafx.sg.prism.NGGroup (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.sg.prism to unnamed module @0x253d5cf1
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:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at ui.PostDisplayandAction.<clinit>(PostDisplayandAction.java:37)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.loadClass(LauncherImpl.java:382)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs(LauncherImpl.java:421)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
我添加了以下虚拟机--module-path /Applications/javafx-sdk-11.0.2/lib --add-modules=javafx.controls,javafx.fxml,javafx.base
我似乎在过去 2 小时内一直在尝试让此代码正常工作。代码中没有编译错误。我犯了什么错误?
您必须添加 --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
,它应该可以工作!
在我的例子中,问题出现在从 jdk13 到 jdk14 之后。 所以你最好在你的编辑器上将它添加到你的虚拟机中:
--module-path /Applications/javafx-sdk-11.0.2/lib --add-modules=javafx.controls,javafx.fxml,javafx.base --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
或者用 --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
也许你可以检查这个问题https://github.com/GSI-CS-CO/chart-fx/issues/6
它帮我解决了这个问题
只需将此内容附加到您的配置中
--module-path /path/to/javafx-sdk-11.0.2/lib --add-modules=javafx.swing,javafx.graphics,javafx.fxml,javafx.media,javafx.web --add-reads javafx.graphics=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.charts=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.iio=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.iio.common=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED
也许有用
我只是将这一行添加到我的 VM 选项中,它就起作用了
--add-modules javafx.web
我在添加WebView时遇到了同样的问题。对我有用的是:
1- 通过转至 File/New/Module 从现有资源 ..
将您的项目变成模块化项目2- 将“requires javafx.web”行添加到您的模块-info.java 文件中,如下所示:
module com.example.demo {
requires javafx.controls;
requires javafx.fxml;
requires javafx.web;
opens com.example.demo to javafx.fxml;
exports com.example.demo;
}
3- 将以下依赖项添加到您的 pom.xml 文件中:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>11.0.2</version>
</dependency>
3- 最后,我将 openJdk 更改为 Amazon Corretto JDK。还要考虑包含开箱即用的 JavaFX 的 Azul Zulu Jdk 版本(您甚至不需要在项目 pom 中包含 JavaFx 依赖项)
我通过进入 Run Configuration
-> VM arguments
并添加以下参数行来修复我的问题:
--add-modules=javafx.swing,javafx.graphics,javafx.fxml,javafx.media,javafx.web
--add-reads javafx.graphics=ALL-UNNAMED
--add-opens javafx.controls/com.sun.javafx.charts=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.iio=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.iio.common=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED
--add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED