tomasz-mer
tomasz-mer

Reputation: 3930

How to load a resource when folder of resources have the same name in the main app and in the library?

In the main app in the resource folder I have a folder named "sci". An app uses a library (as jar as dependency) which also has a folder with the same name in resources.

When I calling getClass().getResource() i got a location of resource located in the jar

/Documents/project/ru-s/app/libs/my-library.jar!/sci 

How to load a resource from main app?

Upvotes: 1

Views: 193

Answers (1)

Joachim Sauer
Joachim Sauer

Reputation: 308249

You can use ClassLoader.getResources() to find all resources of a given name, when they exist in multiple jar files.

So instead of Something.class.getResource("foo") you use Something.class.getClassLoader().getResources("foo") to get an Enumerator over all resources of that name on your classpath.

Upvotes: 1

Related Questions