Thus, there are several ways to get a resource from a jar, and each of them has a slightly different syntax where the path must be given in different ways.
The best explanation I've seen is an article from JavaWorld . I will describe here, but if you want to know more, you should check out the article.
Methods
1) ClassLoader.getResourceAsStream() .
Format: "/" - split names; no leading "/" (all names are absolute).
Example: this.getClass().getClassLoader().getResourceAsStream("some/pkg/resource.properties");
2) Class.getResourceAsStream()
Format: "/" - split names; the leading "/" indicates absolute names; all other names refer to the package of the class
Example: this.getClass().getResourceAsStream("/some/pkg/resource.properties");
greedybuddha May 15 '13 at 17:12 2013-05-15 17:12
source share