HostileNinja72
HostileNinja72

Reputation: 11

How to solve JavaFX runtime components are missing on VS code IDE

I'm using JavaFx on visual studio code IDE. I always get this error:

JavaFX runtime components are missing and are required to run this application

I've already added the VM args and the javafx libraries.

Also some basic FX codes are compiled with ease, but once I use the FXMLLoader class, I get the aforementioned error.

package app;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class App extends Application 
{
    @Override
    public void start(Stage stage) 
    {
        try 
        {
            Parent root = FXMLLoader.load(getClass().getResource("/interfaces/SignIn.fxml"));
            Scene scene = new Scene(root);
            stage.setScene(scene);
            stage.show();
        }
        catch (Exception e) 
        {
            e.printStackTrace();
        }
    }

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

Upvotes: 1

Views: 2276

Answers (1)

Molly Wang-MSFT
Molly Wang-MSFT

Reputation: 9521

In launch.json, adding a new entry for the vmArgs including the --module-path with the local path to the JavaFX SDK and --add-modules with the required JavaFX modules:

"vmArgs": "--module-path /path/to/javafx/lib  --add-modules javafx.controls,javafx.fxml"

Upvotes: 1

Related Questions