Why is my URI not hierarchical? [duplicate]
问题 This question already has an answer here: Java Jar file: use resource errors: URI is not hierarchical 6 answers I have files in resource folder. For example if I need to get file from resource folder, I do like that: File myFile= new File(MyClass.class.getResource(/myFile.jpg).toURI()); System.out.println(MyClass.class.getResource(/myFile.jpg).getPath()); I\'ve tested and everything works ! The path is /D:/java/projects/.../classes/X/Y/Z/myFile.jpg But , If I create jar file, using , Maven :