Over a million developers have joined DZone.

Checking configuration files inside jars

DZone's Guide to

Checking configuration files inside jars

· Java Zone ·
Free Resource

Build vs Buy a Data Quality Solution: Which is Best for You? Gain insights on a hybrid approach. Download white paper now!

Are you habit to have some configuration files packaged inside the jar of your application?

If so, you can still have a look at those configuration files in the running environment using the unzip Unix utility.

$ unzip -p /opt/myapp/lib/my-app.jar log4j.properties

log4j.appender.stdout.layout.ConversionPattern=%d{dd-MMM hh:mm} [%-5p] %m%n

The -p option uncompress and prints the file content to standard output.

I like to include resource files in the deployable artifact, unless I want those files to be modifiable without repackaging. Hiding most of configuration helps to keep things simpler for the end user, but still those files can be accessed for the technical support.

By the way, the above log4j configuration is the one I used to replace some System.out/System.err in a simple command line based application. I was thinking to remove the date part ‘%d{dd-MMM hh:mm}’ and make it look like the output of ant/maven, but then I thought that -after all- the date is quite useful since the application in question is ran by cron redirecting the standard out into a file, so we keep that as a log of the last run, to have some clue in case of errors.

From http://en.newinstance.it/2011/06/01/checking-configuration-files-inside-jars/

Build vs Buy a Data Quality Solution: Which is Best for You? Maintaining high quality data is essential for operational efficiency, meaningful analytics and good long-term customer relationships. But, when dealing with multiple sources of data, data quality becomes complex, so you need to know when you should build a custom data quality tools effort over canned solutions. Download our whitepaper for more insights into a hybrid approach.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}