We’ve developed a custom plugin for Notes 8.5.2. It records a number of custom user preferences. The class that does so is shown below:
import java.util.prefs.Preferences;
/**
* Provides programmatic access to Windows Registry entries for this plug-in.
*/
public class Registry
{
Preferences prefs;
/**
* Initializes a new instance of the Registry class.
*/
public Registry()
{
prefs = Preferences.userNodeForPackage(Registry.class) ;
}
/**
* Gets the value of a registry key.
*
* @param keyName The name of the key to return.
*
* @return A string containing the value of the specified registry key. If a key with the specified name cannot be
* found, the return value is an empty string.
*/
public String GetValue(String keyName)
{
try
{
return prefs.get(keyName, "NA") ;
}
catch(Exception err)
{
return "" ;
}
}
/**
* Sets the value of a registry key.
*
* @param keyName The name of the registry key.
*
* @param keyValue The new value for the registry key.
*/
public void SetValue(String keyName, String keyValue)
{
try
{
prefs.put(keyName, keyValue);
prefs.flush();
}
catch(Exception err)
{
}
}
}
A sample of the code that uses it is as follows:
Registry wr = new Registry();
String setting1 = wr.GetValue("CustomSetting1");
wr.SetValue("CustomSetting1", newValue);
Now, I’ve scanned the Windows Registry, and these settings do not exist. I’ve indexed my entire hard disk, and I cannot find these entries in any file.
So, where the heck are these settings being stored?
On Windows the Java Preferences API uses the Registry as it’s backing store for the
Preferencesclass. The keys are rooted by package name underHKEY_CURRENT_USER\Software\JavaSoft\Prefs.Your code doesn’t specify a package, so it uses the following location by default (tested on Windows Vista and 7):
There is an articled titled “Sir, What is Your Preference?” by Ray Djajadinataz at the Sun Developer Network where you can get a little more background on this API with some screen shots showing registry locations.
I wonder if you were searching for the key name, eg CustomSetting1, and not finding it because it is saved as /Custom/Setting1 to note that the C and S are capitalized (see API docs.)