Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting errors in including the WebView component in JavaFx and scene builder

I am using Eclipse (javafx) and Scene Builder developing an app and I need to use a webview. My program is working smoothly, but when I add a webview component into an anchor pane, I got this error.

Caused by: java.lang.ClassNotFoundException: javafx.scene.web.WebView
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 javafx.fxml/javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2931)
at javafx.fxml/javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2920)
at javafx.fxml/javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2861)
... 16 more
Exception running application view.Main

I tried to use the initialize function but still getting same errors, Can anyone tell me why? Thanks in advance.

like image 884
Ali Hasan Avatar asked Oct 13 '25 09:10

Ali Hasan


1 Answers

After i had this exact same error for a longtime, i solved adding the following arguments on eclipse>run>run configurations... then select the "Arguments" tab and add the text bellow to the "VM Arguments"

--module-path "%PHYSICAL_PATH_TO_JAVAFX%\lib" --add-modules javafx.controls,javafx.fxml,javafx.web

The main problem was that everywhere you go, they tell you to add the controls and fxml modules, but they never say that you may need to add more modules to those arguments. so i added the "javafx.web" and it solved my problem.

like image 67
GRCarvalho Avatar answered Oct 16 '25 11:10

GRCarvalho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!