please guys i want to load images from i jar in a javafx app but it don't show up even though it works in ide just as expected this is the output i get from load function file:/C:/Users/anass/OneDrive/Desktop/anass_coder/target/classes/com/anass/anass_code_editor/assets/languages/ and this is the absolute path of images folder C:\Users\anass\OneDrive\Desktop\anass_coder\src\main\resources\com\anass\anass_code_editor\assets\languages
this is the load function :
public static void loadIconImages() {
iconImages = new HashMap<>();
URL imagesDirURL = App.class.getResource("/com/anass/anass_code_editor/assets/languages");
if (imagesDirURL != null) {
System.out.println(imagesDirURL.toExternalForm());
try {
InputStream imagesDirStream = imagesDirURL.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(imagesDirStream));
String line;
while ((line = reader.readLine()) != null) {
String name = line.trim().toLowerCase();
if (name.contains(".")) {
String resourcePath = "/com/anass/anass_code_editor/assets/languages/" + name;
InputStream imageStream = App.class.getResourceAsStream(resourcePath);
if (imageStream != null) {
iconImages.put(name.substring(0, name.indexOf(".")), new Image(imageStream));
imageStream.close();
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
System.out.println("No dir");
}
}
i am using maven to bundle the desktop app
i tried getRessourcesAsStream ,the uri is not hirarchicall error is gone but ressources are not found the ressources are well bundled and exist in jar archive