I'm trying to make a graph with javafx and I am getting the error: JavaFX runtime components are missing, and are required to run this application

I'm trying to make a graph with javafx and I am getting the error: JavaFX runtime components are missing, and are required to run this application

所以我对 javafx 很陌生,我正在为一些包而苦苦挣扎(我认为)

@Override
public void start(Stage stage) throws Exception {
    // Defining the axes
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(
            FXCollections.<String>observableArrayList(Arrays.asList("Speed", "User rating", "Milage", "Safety")));
    xAxis.setLabel("category");

    NumberAxis yAxis = new NumberAxis();
    yAxis.setLabel("score");

    // Creating the Bar chart
    BarChart<String, Number> barChart = new BarChart<>(xAxis, yAxis);
    barChart.setTitle("Comparison between various cars");

    // Prepare XYChart.Series objects by setting data
    XYChart.Series<String, Number> series1 = new XYChart.Series<>();
    series1.setName("Fiat");
    series1.getData().add(new XYChart.Data<>("Speed", 1.0));
    series1.getData().add(new XYChart.Data<>("User rating", 3.0));
    series1.getData().add(new XYChart.Data<>("Milage", 5.0));
    series1.getData().add(new XYChart.Data<>("Safety", 5.0));

    XYChart.Series<String, Number> series2 = new XYChart.Series<>();
    series2.setName("Audi");
    series2.getData().add(new XYChart.Data<>("Speed", 5.0));
    series2.getData().add(new XYChart.Data<>("User rating", 6.0));
    series2.getData().add(new XYChart.Data<>("Milage", 10.0));
    series2.getData().add(new XYChart.Data<>("Safety", 4.0));

    XYChart.Series<String, Number> series3 = new XYChart.Series<>();
    series3.setName("Ford");
    series3.getData().add(new XYChart.Data<>("Speed", 4.0));
    series3.getData().add(new XYChart.Data<>("User rating", 2.0));
    series3.getData().add(new XYChart.Data<>("Milage", 3.0));
    series3.getData().add(new XYChart.Data<>("Safety", 6.0));

    // Setting the data to bar chart
    barChart.getData().addAll(series1, series2, series3);

    // Creating a Group object
    Group root = new Group(barChart);

    // Creating a scene object
    Scene scene = new Scene(root, 600, 400);

    // Setting title to the Stage
    stage.setTitle("Bar Chart");

    // Adding scene to the stage
    stage.setScene(scene);

    // Displaying the contents of the stage
    stage.show();
}

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

这是我创建条形图的示例代码,我收到错误“JavaFX 运行时间组件丢失,运行 此应用程序需要”。然后我在我的配置中添加了一个 vmargument。由于我使用 vscode 我输入了

"vmArgs": "--module-path /C:/Documents/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml",

进入launch.json。不过在那之后,我得到了错误

“引导层初始化期间发生错误 java.nio.file.InvalidPathException:索引 2 处的非法字符 <:>:/C:/Documents/javafx-sdk-11.0.2/lib”

有什么解决办法吗?

啊我发现了,原来我在vmarguments里面添加模块的地址是错的,马上改正了。