If you are using a "simple maven project", the maven path is the src/main/resources folder. Have you configured your pom.xml to do something else?
If you created the jar creation part correctly, the correct way is to get a file that is in the classpath :
getClass().getResourceAsStream("/path/to/resource.ext");
The leading slash is important!
If the file is NOT in your classpath (in other words, it will be so if it doesn't work), you probably need to configure maven to use a different resource directory.
You do like this (change the arguments if necessary):
<build> ... <resources> <resource> <targetPath>META-INF/plexus</targetPath> <filtering>false</filtering> <directory>${basedir}/src/main/plexus</directory> <includes> <include>configuration.xml</include> </includes> <excludes> <exclude>**/*.properties</exclude> </excludes> </resource> </resources> <testResources> ... </testResources> ... </build>
Then your file will be in your classpath and the above code will work. See the related documentation for more details.
source share