Java: Preferences API vs. Apache Commons Configuration?

Given your example of storing a set of values associated with a key you would seem to have the following options when using each library Preferences - store as a byte array associated with the key Commons Configuration - store as a list of strings associated with a key So the choice could come down to whether it is easier to convert a FooBean into a byte array or a String. The other advantage of Commons Configuration is the different backends. I have used it to store properties in a database.

If you want to store the objects somewhere other than the users local machine it would be the better choice.

I would normally go with Preferences API which is part of JDK unless there are issues which are otherwise solved by commons-config. Personally when I use spring it has a Property Configurer which does most of these for me.

Commons Configuration is not suited for storing complex objects structures. You'd better use a serialization framework.

Well, commons-configuration is, like many of apache project, an abstraction layer allowing one to seemlessly use preferences, an ldap store, properties files, and so on. So, your question could be rewritten as is : Will you need to change the format you use to store your preferences? If no, java preferences are the way to go.

Elsewhere, consider the portability of commons configuration.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions