tags:

views:

176

answers:

3

Hello,

here is a rather newbie question, but it'll be very helpful if you give me some clues.

I am running a Java application (with Gui). Every time I exit the Gui, the session (what I have done in the Gui) is saved, and next time when I start the Gui, the saved session is loaded. When I install the application in another directory, and run the executable file of the newly installed application, the saved session of the old application is loaded. Why does this happen? The applications are the same version, and have the same names, but I thought that when I start the executable file of the newly installed application, a freshly new session will start (and nothing about what I have done in the gui of the other application will be remembered). If I run the application for a second or n-th time, the previous application is saved, probably because there is an option the session to be saved, but why does this happen with the new executable file?

Do I have to change/delete something somewhere in my computer in order this not to happen? (I am trying these things using windows machine).

Regards

+1  A: 

The application is probably saving your preferences in your home directory or Windows registry, i.e. using the Preferences API.

Marc Novakowski
+2  A: 

Java can save its program settings in a Preferences, which in turn is stored in a per user location, based upon what settings are used to store and retrieve the values. On windows boxes these preferences are stored in the registry under HKEY_CURRENT_USER/Software/JavaSoft/Prefs

There may be a large directory tree under this using the class paths of objects to distinguish the values.

Thomas Jones-Low
+1  A: 

Are you using Swing and is your application extending SingleFrameApplication (e.g the default GUI app created in NetBeans). If so, the window state information is saved out - where depends on the platform. To stop this happening, you need to override the shutdown method in your class that extends SingleFrameApplication

@Override
protected void shutdown() {
    super.shutdown();  // remove this if you don't want the window state saved
}
Miles D