Monday, April 9, 2012

Manage java property files using Apache Common Configuration API

Recently I did some research on how to manage the java property file in a better way. I found the Apache Common Configuration API  is actually really good.

I found the following 3 features are really powerful.

1. Variable interpolation
  Like using a variable in Ant, you can use variable in a property file, and Apache Common Configuration API proivide API to expand them on the fly.
code sample

2. Include other property files in a property file
   check this link for details.
property example

Code example:

3. combine multiple property file into one property object
   details are in here.
   Property example

   Code example:

I believe above the 3 features will greatly simply the java property file management.


  1. hi

    I need know where properties files need to placed.
    I my example i have tired placing property file com.yourcompany.application.resources

    how do i will use this in the above code.

    with regrads

  2. you just need to put your property file under the class path