Preferences : Java Glossary

Preferences
java.util.prefs.Preferences first appeared in Java 1.4.1 as way to store configuration data for applications and individual users.

Advantages of Preferences

Disadvantages of Preferences

Use

systemNodeForPackage lets you specify Preferences for the whole machine for each package. userNodeForPackage lets you specify Preferences for a particular user for that package. If the package is used in more than one context, e.g. the same class used in two different programs or the same class is used to manage two separate sets of files, it is up to you to create another level of name to keep track of the context. Note though you specify a class name, the Preferences are on a per package, not a per class basis.

The registry will be more legible with regedit if you stick to lower case keys and values since upper case values are encoded in a bizarre fluffy way.

Location

Tips

Alternatives include writing data to a server, storing it in an SQL database, storing in a POD (Persistent Object Database) and storing in ini, CSV (Comma Separated Value), DataOutputStream or serialised disk files.

Learning More

The Replicator uses the Preferences mechanism to persist configurations option for the client as does Submitter and VerCheck. You can examine the source code to see a real world application.
Oracle’s Javadoc on Preferences class : available:

CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/preferences.html J:\mindprod\jgloss\preferences.html
logo
Please email your , letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email. If you want your message, your name or email kept confidential, not considered for public posting, please explicitly specify that. Unless you state otherwise, I will treat your message as a letter to the editor that I may or may not publish in the feedback section. After that, it will be too late to retract it. If you disagree with something I said, please quote it and cite the web page where you found it, tell me why you think it is wrong, and, if possible, provide some supporting evidence. Threatening to kill me or spouting obscenities has yet to persuade me to change my mind.
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.179.212]
You are visitor number 25,607.