Skip to content

What is the proper way to store app’s conf data in Java?

Where do you store user-specific and machine-specific runtime configuration data for J2SE application?

(For example, C:UsersUSERNAMEAppDataRoaming</em> on Windows and /home/username on Unix)

How do you get these locations in the filesystem in platform-independent way?



That depends on your kind of J2SE Application:

  • J2SE executable JAR file (very simple): use user.home System property to find home-dir. Then make a subdir accordingly (like e.g. PGP, SVN, … do)
  • Java Web Start provides very nice included methods to safe properties. Always user-specific
  • Finally Eclipse RCP: There you have the notion of the workspace (also derived from user.home) for users and configuration (not totally sure how to access that tricky in Vista) for computer wide usage

All these approaches are, when used with care — use correct separatorChar — OS neutral.