I am using maven and I am creating an application that needs to get files from src/main/resources
upon running an exe
.
I used this to generate an exe upon build > http://www.hascode.com/2012/08/creating-a-windows-executable-from-a-jar-using-maven/
I am getting an error that it cannot access the files inside src/main/resources
when running the exe
file.
I use this to get the files from src/main/resources
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
File[] files = new File(classLoader.getResource("files").getFile()).listFiles();
When I run it in eclipse, it runs but when I run it using exe,
using eclipse: No error
DEBUG file:/C:/Development/Java/eclipse/workspace/app_sample/target/classes/files
DEBUG /C:/Development/Java/eclipse/workspace/app_sample/target/classes/files
using exe:
DEBUG file:/C:/Users/User.Name/Desktop/just%20some%20directory/App.exe!/files
ERROR java.lang.NullPointerException