properties file in a jar

Discussions

General J2EE: properties file in a jar

  1. properties file in a jar (2 messages)

    Hi;

    I want users to be able to put a properties file in a jar file instead of having to have it be a seperate file in the directory.

    How should I go look for it so it can be in either location?

    thanks - dave

    Threaded Messages (2)

  2. properties file in a jar[ Go to top ]

    Put all of your property files in the classpath, and load them using the Java classloader. The Class.getResourceAsStream() method is useful here.

    Since you are retrieving the files using the classloader, you can get files from both JARs and from the file system (provided that the directories in the file system are in the classpath). Your application will use whichever property file appear first in the classpath.
  3. properties file in a jar[ Go to top ]

    thanks