I'm looking for a simple, cross-platform way, on the JVM, to get the appropriate directories for storing application settings and cache data. E.g., on Linux under the XDG specs:

  • config in ~/.config/appname
  • cache in ~/.cache/appname

Windows stuff goes in C\Users\user\Application Data or some such (on Win 7); I gather that Mac puts stuff under ~/Library/Application Settings.

Is there a cross-platform call to get these path locations? I haven't been able to find one, though I find several questions asking about it. Is there some library that has implemented the correct logic for most common desktop platforms?

Worst case, I can just look up user.home and pretend everything is an XDG-based Linux environment. But if it's easy to get the right directories for the user's OS, I'd like to do so.

Edit
Report