Skip to content
Advertisement

Java VMOptions in VSCode

I’m attempting to run a simple JavaFX shown here;

@Override
public void start(Stage stage) throws Exception {
    Group root = new Group();
    Scene scene = new Scene(root, Color.WHEAT);

    stage.setTitle("Testing");
    stage.setWidth(400);
    stage.setHeight(400);

    stage.setScene(scene);

    stage.show();
}

}

My VMOptions (stored in the default launch.json file) are as follows;

    {
        "type": "java",
        "name": "Launch Main",
        "request": "launch",
        "vmArgs": "--module-path C:/Program Files/Java/javafx-sdk-17.0.1/lib --add-modules=javafx.controls,javafx.fxml",
        "mainClass": "Main",
        "projectName": "Dump_661a224e"
    }

However, I keep getting the following

error

I’ve followed countless tutorials and ensured that all the syntax and file locations are correct. Any help is appreciated.

Advertisement

Answer

Put your JavaFX SDK in a location without a space in the path and update your options accordingly to point to the new location.

Your current runtime configuration is treating the space in the path as an argument separator.

You could probably also fix the issue by appropriately quoting the path with the space in it. To place a quoted string in json, you need to escape the quotes.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement