Module not found: javafx.controls

Oksana Oryekhovska :

I have downloaded JavaFX SDK, unpacked it and set a PATH_TO_FX system variable, following this instructions. I used following code example:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class HelloFX extends Application {

    @Override
    public void start(Stage stage) {
        String javaVersion = System.getProperty("java.version");
        String javafxVersion = System.getProperty("javafx.version");
        Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
        Scene scene = new Scene(new StackPane(l), 640, 480);
        stage.setScene(scene);
        stage.show();
    }

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

Tried to compile it with the suggested pattern:

javac --module-path $PATH_TO_FX --add-modules javafx.controls HelloFX.java

But compiler throws an error: module not found: javafx.controls. Windows 10. Java and JavaFX versions is 11.0.1

Again: I DID ADD the line --add-modules javafx.controls

Oksana Oryekhovska :

The problem was solved in 3 steps.

  1. Use %PATH_TO_FX% instead of $PATH_TO_FX in the command line.

  2. Recreate the variables (both system and user) PATH_TO_FX enclosing its value in quotation marks. As the directory "C:\Program Files\Java\javafx-sdk-11.0.1\" contains a space, it caused an error "invalid flag".

  3. Rebooting the computer to update the variables.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=106684&siteId=1