0

I want to code a small web browser using JavaFX Web View. Here's my current code:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewExample extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    public void start(Stage primaryStage) {
        primaryStage.setTitle("JavaFX WebView Example");

        WebView webView = new WebView();

        webView.getEngine().load("http://google.com");

        VBox vBox = new VBox(webView);
        Scene scene = new Scene(vBox, 960, 600);

        primaryStage.setScene(scene);
        primaryStage.show();

    }
}

When I want to compile it using

javac -p /Users/xamsoftware/javafx-sdk-11.0.2/lib --add-modules=javafx.controls WebViewExample.java

It says

WebViewExample.java:4: error: package javafx.scene.web is not visible
import javafx.scene.web.WebView;
                   ^
  (package javafx.scene.web is declared in module javafx.web, which is not in the module graph)
1 error

Is there anybody that can help me?

Lagol
  • 1

1 Answers1

0

So responding to one comment, you basically have to change --add-modules=javafx.controls to --add-modules=javafx.web.

Lagol
  • 1