Preferences : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

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:

This page is posted
on the web at:

http://mindprod.com/jgloss/preferences.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\preferences.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[3.15.147.215]
You are visitor number