Reputation: 603
If I use the Preference API to store user or system preferences, where are they stored on Windows and Unix?
Upvotes: 29
Views: 20039
Reputation: 7937
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
Upvotes: 41
Reputation: 1640
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.
HKEY_CURRENT_USER\Software\JavaSoft\Prefs
HKEY_CURRENT_USER\Software\JavaSoft\Prefs
HKEY_CURRENT_USER\Software\Wow6432Node\JavaSoft\Prefs
System.getProperty("java.util.prefs.userRoot")
or (if the previous value is not set) ~/.java/.userPrefs
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs
HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Prefs
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
.)Upvotes: 14