After I've searched for a solution for my problem & reading similar questions which are very more professional than mine,... well, I hope you pay attention to my problem, even though it seems simple! I'm working on a project which open files by FileChooser, then I'm trying to show it on a pane. The problem is getClass().getResourceAsStream(file.getAbsolutePath()) returns null.So while I can print the path & see it's true, but I cannot use it in creating images. Part of my code is:
FileChooser fileChooser = new FileChooser();
File file = fileChooser.showOpenDialog(stage);
...
Image img = new Image(getClass().getResourceAsStream(file.getAbsolutePath());
The exception is:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Input stream must not be null ...
I work on Ubuntu by NetBeans. I really appretiate helps. Thanks.