I have a nasty problem referencing resources when using a Maven project and Jar files...
I have all my resources in a dedicated folder /src/main/resources which is part of the build path in Eclipse. Files are referenced using
getClass().getResource("/filename.txt")
This works fine in Eclipse but fails in the Jar file - there the resources are located in a folder directly below the jar's root...
Does anyone know a 'best practice' to reference a file both in the JAR and (!) in Eclipse?
Edit:
The problem is that while the resources actually are located in the JAR in a folder "resources" at the top level, the above method fails to find the file...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…