Two Laptop Bag
The moose likes Java in General and the fly likes Loading Configuration files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Loading Configuration files" Watch "Loading Configuration files" New topic

Loading Configuration files

Cindy Jones
Ranch Hand

Joined: Oct 08, 2002
Posts: 66
I need to use config files in my application. My requirement is roughly as follows:

I have different properties that have different values in different environments
I would like my properties file to be an xml
I would prefer to use the same deployable in all environments with no modifications.

My plan is as follows:
Use apache commons configuration (xml)
Define separate configuration files for different environments(Dev, Qa, Prod)
Identify the environment to use using a JVM argument.

My question is:
What is the standard way of loading the configuration file? Have a singleton class that loads the config file and that has a get method?

Jeff Storey
Ranch Hand

Joined: Apr 07, 2007
Posts: 230

I have used a singleton like you suggested in the past and it works quite well. That should be as good an approach as any.

I agree. Here's the link:
subject: Loading Configuration files
It's not a secret anymore!