I'm trying to make an executable JAR so that anyone can download and run my application.
I'm trying to grab the path of a directory full of images so that I can traverse all images in the folder to perform some action on each one. It works fine when run from the IDE (Netbeans), but when run from the JAR file it doesn't work.
The folder that contains the images is located in the src folder -> graphics -> Textures.
Here is my code:
Path terPath = Paths.get(getClass().getResource("/graphics/Textures").toURI());
List<File> filesInFolder = Files.walk(terPath)
.filter(Files::isRegularFile)
.map(Path::toFile)
.collect(Collectors.toList());
The error happens in the first line when run from a JAR, but works perfectly fine when run from the IDE.
Thanks for your help.