Noam
Noam

Reputation: 19

The type javafx.fxml.FXMLLoader is not accessible

I'm working on a project in Eclipse and I want to make use of JavaFX for my GUI. I installed JavaFX and I added it to my project library. When I try to import "import javafx.fxml.FXMLLoader;" there is an error:"The type javafx.fxml.FXMLLoader is not accessible". image: https://ibb.co/QmpFKDF

code:


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


public class Hello extends Application {
       public void start(Stage stage) throws Exception {
               Parent root = FXMLLOADER.load(getClass().getResource(
                       "Hello.fxml"));
               Scene scene = new Scene(root);
               stage.setTitle("Hello");
               stage.setScene(scene);
               stage.show();
       }

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

   }
}

Thanks.

Upvotes: 0

Views: 5055

Answers (1)

Renis1235
Renis1235

Reputation: 4700

First of all Java is case-sensitive as mentioned in the comments. Use FXMLLoader.load().

From your screenshot, the IDE recognizes the import line as an error line too. So your JavaFX Library has not been correctly imported.

You have to follow the correct steps to get it to work. Here are some Tutorials that you can follow:

  1. https://gist.github.com/stevenliebregt/bc62a382fc43064136b662ee62172ab3
  2. How to add JavaFX runtime to Eclipse in Java 11?
  3. https://openjfx.io/openjfx-docs/

Upvotes: 2

Related Questions