How to resolve 'Error: Javafx Runtime components not found' java 11 ( linux )

Asked

Viewed 1,461 times

0

I downloaded the Javafx Sdk for Java Platform 11 and I’m trying to open my FXML, but when I try to run my program it gives the following error:

  static String uId;

  public static void main(String[] args){
    // Código ...
    if (user.username == null){uId = null}
    Application.launch(args);
}

@Override
public void start(Stage arg0) throws Exception {
    URL fxml = getClass().getResource("./LG.fxml");
    Parent fxmlParent = (Parent) FXMLLoader.load(fxml);
    arg0.setScene(new Scene(fxmlParent));
    arg0.setTitle("Tela de Login");
    if (uId == null) {
        System.out.println("Visualizando janela de Login");
        arg0.show();
    }else {

    }
}

"Error: Javafx Runtime components not found. They are required to run this application"

How I fix it and what’s causing it?

Note: I am using Eclipse IDE on Ubuntu 18.04 if help :D

1 answer

1


There is a step-by-step Javafx for this, and there it shows when this error occurs and how to solve: "Getting Started with Javafx 12" (in this case, it is updated to version 12 of Javafx, but I did the same for version 11 of Javafx along with Openjdk12 and it worked).

inserir a descrição da imagem aqui

As explained in the link step-by-step, you need to add some VM Arguments for running the project with Javafx:

--module-path /path/to/javafx-sdk-12.0.1/lib --add-modules javafx.Controls,javafx.fxml

Replace the /path/to/javafx-sdk-12.0.1/lib through the library path on your computer.

In addition, you may have already added Javafx as a library in the project (this is required from version 9 of Java), as explained in this step-by-step.

I recommend you follow (or at least study) this entire step-by-step, but the solution to this problem for Eclipse is in the side menu item JavaFX and Eclipse.

Note: for me it seems unnecessary to install the extension Java 12 Support for Eclipse 2019-03 (4.11) that step-by-step suggests installing (in addition to it still being in Beta, what I saw she does is simply allow testing one or more experimental features in Java12), i did not install; and extension installation E(fx)clipse is optional.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.