import java.util.prefs.NodeChangeEvent; import java.util.prefs.NodeChangeListener; import java.util.prefs.Preferences; public class Main { public static void main(String[] argv) throws Exception { Preferences prefs = Preferences.userNodeForPackage(String.class); prefs.addNodeChangeListener(new NodeChangeListener() { public void childAdded(NodeChangeEvent evt) { Preferences parent = evt.getParent(); Preferences child = evt.getChild(); } public void childRemoved(NodeChangeEvent evt) { Preferences parent = evt.getParent(); Preferences child = evt.getChild(); } }); Preferences child = prefs.node("new node"); child.removeNode(); prefs.removeNode(); } }