If I use the Preference API to store user or system preferences, where are they stored on Windows and Unix?
Asked
Active
Viewed 1.9k times
2 Answers
39
For Windows systemRoot and userRoot are stored in HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs and HKEY_CURRENT_USER\Software\JavaSoft\Prefs respectively.
For Unix systemRoot and userRoot are stored in "/etc/.java" and "${user.home}/.java/.userPrefs", respectively.
Note that for Unix the locations can be changed by specifying "java.util.prefs.userRoot" and "java.util.prefs.systemRoot" properties
-
1On my UNIX box (which is Mac OS X), I get them in ~/Library/Preferences in multiple plist files. :> – Hakanai Apr 24 '14 at 01:08
-
Mac OS X uses the java.util.prefs.MacOSXPreferencesFactory class. See http://lists.apple.com/archives/java-dev/2010/Jul/msg00056.html for a discussion. – Richard Neish Jun 11 '14 at 08:09
-
@RichardNeish I don't see a `MacOSXPreferencesFactory` class in my Mac's JDK: http://i.imgur.com/wWDryFT.png – Ky - Jul 27 '15 at 23:09
-
@BenC.R.Leggiero the `java.util.prefs.MacOSXPreferencesFactory` class should be in `rt.jar` in JDK 1.7 or later. I don't have a Mac, so can't comment further. See http://hg.openjdk.java.net/macosx-port/macosx-port/jdk/file/65910faed942/src/macosx/classes/java/util/prefs for the source code. – Richard Neish Jul 28 '15 at 08:07
-
@RichardNeish well, I'm compiling on JDK 8... and, here's all the items in `java.util.prefs`: http://i.imgur.com/GdpGIVf.png – Ky - Jul 28 '15 at 12:33
14
I have to extend n002213fs' answer, because it seems to me, that the Storage Location is a big mess. Note that Windows saves it in the Windows Registry and Unix saves it in prefs.xml-files.
userRoot
- Windows (32Bit):
HKEY_CURRENT_USER\Software\JavaSoft\Prefs
- Windows (64Bit) with JVM (64Bit):
HKEY_CURRENT_USER\Software\JavaSoft\Prefs
- Windows (64Bit) with JVM (32Bit):
HKEY_CURRENT_USER\Software\Wow6432Node\JavaSoft\Prefs
- Unix:
System.getProperty("java.util.prefs.userRoot")
or (if the previous value is not set)~/.java/.userPrefs
systemRoot
- Windows (32Bit):
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs
- Windows (64Bit) with JVM (64Bit):
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs
- Windows (64Bit) with JVM (32Bit):
HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Prefs
- Unix:
System.getProperty("java.util.prefs.systemRoot")
or (if the previous value is not set)System.getProperty("java.home")+"/.systemPrefs"
(System.getProperty("java.home")
might be/etc/.java/
. You can check it in a terminal with$JAVA_HOME
.)

MyPasswordIsLasercats
- 1,610
- 15
- 24
-
1For Unix, note that `FileSystemPreferences` always adds the `.java/.userPrefs` root onto the configured path. Therefore the equivalent default property setting for `java.util.prefs.userRoot` is really just the home directory (or `~` as you put it). – Dan Gravell Apr 30 '18 at 14:52