Friday, March 09, 2007

Placing your outside your application JAR

If you want to deploy your application as a JAR, and DO want it to be configurable via a 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/ file add the directory location (relative to the jar itself) of your 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, 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.

1 comment:

Anonymous said...

thanks for you comments.
Let me say i have a file at the same directory as abc.jar and if i give "." as the "class-path" how can we read the properties file?
I would like to see the code snippet to do that.