I want to load an HTMLfile in the WebView
of my JavaFX application. The file is located in my project directory, inside webviewsample
package.
I've used the following code :
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("WebView test");
WebView browser = new WebView();
WebEngine engine = browser.getEngine();
String url = WebViewSample.class.getResource("/map.html").toExternalForm();
engine.load(url);
StackPane sp = new StackPane();
sp.getChildren().add(browser);
Scene root = new Scene(sp);
primaryStage.setScene(root);
primaryStage.show();
}
But it throws an exception saying :
Exception in Application start method java.lang.reflect.InvocationTargetException