javaregistrypreferences

Is there some sort of Java-Registry?


Is there some sort of Registry which comes with JRE and doesn't change with a JRE-Update? I want to save some values - like Window-Positions, used Paths or License - but don't want to save them into a file.

An alternative would be an encrypted-file (for example a license-file) or a xml-file (for example an option-file).


Solution

  • You can use the Java Preferences API for this:

    http://docs.oracle.com/javase/6/docs/api/java/util/prefs/Preferences.html

    But I agree with Jon Skeet that storing this kind of things in a file is better. It is easier to work with when e.g. changing the computer or synchronizing this between different computers.

    You could use a Properties file for that.