import java.util.prefs.Preferences;
...
// get object for storing Preferences for MyClass
private Preferences userPrefs = Preferences.userNodeForPackage( MyClass.class );

// alternatively
Preferences userPrefs = Preferences.userRoot().node( "/com/mindprod/replicator/MyClass" );

// get object for a subnode under which can store key=value pairs.
private Preferences fruits = Preferences.userNodeForPackage( MyClass.class ).node( "fruits" );

...
// store Preferences, key=value
userPrefs.putInt( "width", width );
userPrefs.putInt( "height", height );
// make sure preferences are flushed to backingstore.
userPrefs.flush();

...
// fetch Preferences, key, default
int width = userPrefs.getInt( "width", 100 );
int height = userPrefs.getInt( "height", 200 );