Platform's default preferene location

Hi all,

Is there a standard method of obtaining the default user's preference file location?

For example, for Unix and Linux OSes, this would default to a hidden file on the home folder, e.g., ~/.myjavaapp/

For Mac OS X, this would return something like ~/Library/Application Preferences, etc.

Another related question is that is there a way to obtain the default user's home directory?

Thanks.

[433 byte] By [honhwanga] at [2007-11-26 23:00:32]
# 1

1. there is an API to write/read preferences without knowing where they are. for example in windows they are saved in the registry and you can't access that with out JNI (or use this API).

//get preferences

Preferences preferences=Preferences.userNodeForPackage(MyClass.class);

//put some string value and so on....

preferences.put(key,value);

2. in order to get the user home you can get the system property "user.home" like the following:

String userHome=System.getProperty("user.home");

sushika at 2007-7-10 13:06:46 > top of Java-index,Desktop,Developing for the Desktop...