Where to place config files in JARs?

295 views Asked by At

My JAR currently has the following structure:

myapp.jar
    META-INF
        MANIFEST.MF
    net
        myapp
            MyAppDriver.class (fully qualified as net.myapp.MyAppDriver)
            <lots of other classes>

My app requires the need to read a file from the runtime classpath, and configure itself based on the contents of the file (simplelogger.properties from the SLF4J framework).

Where do I place simplelogger.properties in the JAR? Do I need to set anything inside MANFIEST.MF as well?

Thanks in advance!

1

There are 1 answers

0
Kelsey Francis On

You can place the file in any JAR anywhere you would like. If you want it to live alongside MyAppDriver.class, for example, you could then call getClassLoader().getResourceAsStream("net/myapp/simplelogger.properties") to get an InputStream to that file. You don't need a manifest for this to work.