avernet
avernet

Reputation: 31763

Where are Java preferences stored on Mac OS X?

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?

Upvotes: 48

Views: 57798

Answers (3)

csharpfolk
csharpfolk

Reputation: 4290

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.

Upvotes: 0

avernet
avernet

Reputation: 31763

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.

Upvotes: 23

Todd Gamblin
Todd Gamblin

Reputation: 59857

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.

Upvotes: 59

Related Questions