After hours I am giving up on debugging the following:
This works:
URL[] urls = ((URLClassLoader) MyClass.class.getClassLoader()).getURLs();
URL myURL = null;
for (URL url : urls) {
if (url.getPath().endsWith("some.jar")) {
myURL = url;
}
}
System.out.println(myURL);
returns
file:/C:/Users/Me/.m2/repository/path/to/some.jar
However, all of the following returns null
:
MyClass.class.getClassLoader()).getResource("/some.jar");
MyClass.class.getClassLoader()).getResource("some.jar");
MyClass.class.getClassLoader()).getResource("/C:/Users/Me/.m2/repository/path/to/some.jar");
MyClass.class.getClassLoader()).getResource("/path/to/some.jar");
As you can see, I would like to get a jar of the user's maven repository by not adressing it absolutely, if possible. The jar is in the classpath, as shown by getURLs()
But how the heck do I have to address it in getResource()
in order to get it?
Any help is appreciated!