when I try to get a WebPage
with the class com.sun.javafx.webkit.Accessor
, I always see the following exception:
Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class application.Main$1 (in unnamed module @0x22c53437) cannot access class com.sun.javafx.webkit.Accessor (in module javafx.web) because module javafx.web does not export com.sun.javafx.webkit to unnamed module @0x22c53437
at application.Main$1.run(Main.java:144)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
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:184)
at java.base/java.lang.Thread.run(Thread.java:833)
I found this article Cannot access JavaFX class "WebPage" in IntelliJ-IDEA but I don't know how to integrate this. I am using javafx sdk 17.0.1 and jdk-17 (JavaSE-1.8).
EDIT:
For example, this doesn't work:
WebView webView = new WebView();
webView.getEngine().loadContent("<html><bodx><p>test</p></body></html>");
WebPage page = Accessor.getPageFor(webView.getEngine());
System.out.println(page);
But now it says:
Exception in Application start method
I already tried to update to JavaSE-17 and to set the VM Argument:
--add-exports javafx.web/com.sun.webkit.dom=ALL-UNNAMED
and
--add-exports javafx.web/com.sun.webkit=ALL-UNNAMED
but nothing changed.