Question: I have a SWT Java app that runs on Windows XP / Vista / 7 and Mac OS X. I'm currently saving a config file to:

System.getProperty("user.home") + filename

With the changes in security in Windows Vista and Windows 7 this doesn't seem to be the best place to save it anymore.

This file saves information such as registration key info and it is annoying for my users if the file can't be saved or is deleted.

Is there a better path I should use?

Also, what's the preferred path for per user application data on Mac OS X?

Answer: 
What changes in security? I understand they prohibited writing in Program Files, I didn't know they forbid to write in user home.  

It would be a serious compatibility break, I have a number of applications writing there, either directly a file, or in a folder ("hidden" at the Unix mode, ie. prefixed with a dot).  

Now, it seems to be more "friendly" to write in [Application Data folder](https://stackoverflow.com/questions/1198911/how-to-get-local-application-data-folder-in-java "How to get local application data folder in Java? - Stack Overflow") as do a number of other applications (but rarely cross-platform applications which seem to use the previous solution...) but the exact location seems hard to find in Java, and would need a platform detection to do something else on other platforms.

An alternative seems to be to use the [Preferences API](http://java.sun.com/j2se/1.4.2/docs/guide/lang/preferences.html "Preferences API"), ie. [java.util.prefs.Preferences](http://java.sun.com/javase/6/docs/api/java/util/prefs/Preferences.html "java.util.prefs.Preferences").
Sun itself, with its java control panel, had the very same problem ([bug 6487334)](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6487334): their control panel, running at different integrity level, could not both read/write to their deployment directories.

They moved it to `c:\users\<username>\appdata\local`, but had to not rely on `System.getProperty("user.home")` because to this day, it uses a registry KEY that can be set to incorrect value if windows is "tweaked": [bug 6519127](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519127)

So the question [How to get local application data folder in Java?](https://stackoverflow.com/questions/1198911/how-to-get-local-application-data-folder-in-java), using `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\*` is the right place to start looking for read/write access for your settings.  

You can read it with, for instance, [SWT Win32 Extension](http://feeling.sourceforge.net/) project.

The interest to keep your data within the user's homedir is that they will be part of the user's profile which can be a [*roaming* profile](http://blogs.msdn.com/oldnewthing/archive/2005/06/30/434209.aspx), saved at logoff and restored at logon (used quite often on corporation's workstations)