Apache Commons Configuration works great. It supports having the configuration stored in a wide range of formats on the backend including properties, XML, JNDI, and more. It is easy to use and to extend. To get the most flexibility out of it use a factory to get the configuration and just use the Configuration interface after that.
Two feature of Commons Configuration that differentiate it over a straight Properties file is that it support automatic conversion to common types (int, float, String arrays) and it supports property substitution:
server.host=myHost
server.url=http://${server.host}/somePath
If your hardcoded values are just simple key-value pairs, you should look at java.util.Properties. It's a lot simpler than xml, easier to use, and mind-numbingly trivial to implement.
If you are working with Java and the data you are storing or retrieving from disk is modeled as a key value pair (which it sounds like it is in your case), then I really can't imagine a better solution.
I have used properties files for simple configuration of small packages in a bigger project, and as a more global configuration for a whole project, and I have never had problems with it.
Of course this has the huge benefit of not requiring any 3rd party libraries to utilize.
Here are various options:
You might want to read Comparison of Commons Configuration With JFig and JConfig and Configuring your Applications using JFig for some feedback from various users.
Personally, I've used jConfig and it was a good experience.
Commons Configuration
We're using this. Properties files alone are much easier to handle, but if you need to represent more complex data commons configuration can do this and read your properties files as well.
If you aren't doing anything complicated I'd stick to properites files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With