tsa
tsa

Reputation: 25

Java Acces resources from inside JAR in multi JAR application

My java application consists of two JARs and resource folder, one of the JARs contain a class inside a somepackage and it needs to load a resource file from resources folder in the root of the application outside the JAR contain this class how can this class load the resource file with getClass().getResource() or other method

File Structure

    Main Application 
    -resources
    -jar_1 
    -jar_2 
       -com
          -somepackage

Upvotes: 0

Views: 97

Answers (1)

João Marcos
João Marcos

Reputation: 3972

Try this solution:

getClass().getClassLoader().getResourceAsStream("resources/"+docLocation);

Upvotes: 0

Related Questions