I have a program that uses getClass().getClassLoader().getResource() to get the URL in a directory, it works fine when in eclipse, but after jared returns null.
According to this URL: http://www.coderanch.com/t/385935/java/java/getResource-path-fails-Jar
The problem is because the path itself did not exist in the bank. The files with the specified path, but not the path itself . I used the Export command "Runnable JAR File" in Eclipse. When I tried the older Jar File export to create a jar, I noticed the โ add recording directory โ checkbox, and that was the solution. For a Jar file, you need a directory entry by itself in the jar for getResource () in order to return the URL for the path.
But in maven I canโt find such commands for โadding directory entriesโ when packing, can someone tell me? Many thanks!
Env: eclipse 3.5, m2eclipse, maven 2.2.1
java jar
smallufo
source share