Showing posts with label jar java manifest properties config howto tip. Show all posts
Showing posts with label jar java manifest properties config howto tip. Show all posts

Friday, March 09, 2007

Placing your config.properties outside your application JAR

If you want to deploy your application as a JAR, and DO want it to be configurable via a config.properties file, but DON'T want folks to have to crack open your JAR to update it you'll need to do the following.

In the META-INF/manifest.mf file add the directory location (relative to the jar itself) of your config.properties file to the "class-path" attribute. E.g. if your file is going to be in the same directory as the jar, then add "." to the end. If it's going to sit in ./config, then put this in the path.

NOTE: Remember, manifest.mf files have a maximum line length. Go over it and things get confusing. For more information on JARs and manifests see the Sun guide.

Thanks to Rob Newsome for his help in figuring this out.