What's Your Preference – Properties or Preferences?

As I mentioned in my earlier post, I spend some of my time on building a rich UI application using Swing. And when it came to choosing a mechanism to store my user preferences, I decided to not use property files which was how I had stored preferences before. But, now (since Java 1.4) I use the java.util.Preferences API to store and retrieve my preferences. I would not store sensitive information in preferences, but for non-sensitive info, Preferences API is a great way to persist and manage them. The reason I am posting this is that while talking to some of my friends I realized that not many were aware of the Preferences API despite it being around for a while now. Perhaps because most of us have been focussed on server-side software where we have many other options to store preferences such as JNDI registry or a centralized configuration management system. Anyway, if you are building a stand-alone Java application or a rich client and have a need to store user preferences, take a look at the Preferences API. I think it is a cool API.

Some references:

YouRIt

Advertisements

Published by

deepakalur

Cofounder & CTO @ Chartcube.com