46

On Windows, the Java preferences, which you access in your application from java.util.prefs.Preferences are stored in the registry. Where are those stored on Mac OS X?

avernet
  • 30,895
  • 44
  • 126
  • 163
  • I have not found this to be true in Windows 7. – javamonkey79 Feb 09 '11 at 16:12
  • @javamonkey79, are you saying that your application Java preferences (accessed through java.util.prefs.Preferences) are not stored in the Windows registry on Windows? In my experience, and based on what I can read online, they are. For instance, see: http://java.sun.com/developer/technicalArticles/releases/preferences/ – avernet Feb 09 '11 at 23:13
  • Look at the date of the article - it is from 2001...long before Windows 7 :) I have found that they are no longer in the same place. – javamonkey79 Feb 10 '11 at 19:09
  • So you are saying that on Windows 7 the JVM isn't storing preferences in the registry anymore? This is not the subject of this question, but could you share with us more details on where it is stored? – avernet Feb 15 '11 at 17:52
  • 2
    On my Windows 7, both user and system preferences are saved in the registry. At /HKEY_CURRENT_USER/Software/JavaSoft/Prefs/, HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Prefs/ and some at HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/JavaSoft/Prefs/ for 64bits. – Alex Feb 27 '12 at 08:22

3 Answers3

56

From Apple Developer Connection:

The preferences files generated by the Preferences API are named com.apple.java.util.prefs. The user’s preferences file is stored in their home directory (~/Library/Preferences/). The system preferences are stored in /Library/Preferences/ and are only persisted to disk if the user is an administrator.

Todd Gamblin
  • 58,354
  • 15
  • 89
  • 96
22

Also, note that if the preference is nested enough, it won't directly be in com.apple.java.util.prefs, but rather in its own file. For instance, if you have a node /a/b/c, the key/value pairs for that node will be stored in a.b.c.plist.

The file will be either in ~/Library/Preferences/ or /Library/Preferences/, as for the com.apple.java.util.prefs file.

bmargulies
  • 97,814
  • 39
  • 186
  • 310
avernet
  • 30,895
  • 44
  • 126
  • 163
0

When I create preferences objects using code:

package pl.marcinchwedczuk.iunrar.gui;

public class AppPreferences {
    private final Preferences preferences = Preferences
            .userNodeForPackage(AppPreferences.class);

Then the settings will be stored in:

/Users/$USER/Library/Preferences/pl.marcinchwedczuk.iunrar.plist

(for some reason gui part is missing, tested on macOS BigSur).

Also remember to call .flush() on preferences objects.

csharpfolk
  • 4,124
  • 25
  • 31