Issue
I'm trying to put a image from disk in my project, but I don't know from where to load it.
primaryStage.setTitle("Load Image");
StackPane sp = new StackPane(); //**stack pane**
Image img = new Image("mario.png"); // **here is my issue**
What place do I put in the img path?
ImageView imgView = new ImageView(img);
sp.getChildren().add(imgView);
// Adding HBox to the scene
Scene scene = new Scene(sp, 400, 400);
primaryStage.setScene(scene);
primaryStage.show();
Solution
You can create a "resources" package and copy your images and other files this package and for reading an image you can use following line:
Image img = new Image(getClass().getResource("/resources/image.jpg").toURI().toString());
ImageView iv = new ImageView(img);
Answered By - GltknBtn