I have a JAR archive with java classes. One of them uses some resource embedded in the same JAR. To download this resource, I use
MyClass.class.getResourceAsStream(myResourceName);
One thing that bothers me is whether it is guaranteed that the required resource will be loaded from one JAR. The documentation for the getResourceAsStream () method (and the corresponding ClassLoader method) is not entirely clear to me.
What happens if a resource with the same name is somewhere in the JVM classpath before my JAR? Will this resource be loaded instead of the built-in in my JAR? Is there any other way to replace a resource embedded in a JAR?
Axl
source
share