I created a game in Java, and for the game I need to save gaming configurations in files, and all files are in resources/team/. In order to open, create and delete teams I get all filenames in this directory using listFiles() and "src/main/resources/team/" as directory path.
The problem is that in Intellij IDEA it works perfectly both from Main and from JAR-file, but if I try to run it in console java -jar Game.jar
or open it from folder with Java, I get NullPointer from Scanner, because in directory /team/ is simply in root of JAR, without src/main.
I tried to replace it with Directory Streams and some other solutions for getting filenames, but they all use File, so I still need to write "src/main" for it to work in IDEA. Is there any possible way to change it with relative paths for /team/ in JAR or different way to get filenames using getResourceAsStream, so I could use only this with directories in resources, without listFiles()? Also I use Maven, I supposed, It's possible to solve it in pom.xml, but I couldnt find any information about it.