• Post Reply Bookmark Topic Watch Topic
  • New Topic

OS Agnostic Application Settings Location  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a desktop application and am using the Preferences API for general application preferences but I also need to store a few other settings as well as having a general work directory where I can store application files. I'll be starting with the "user.home" as the starting path.

What I want is something like

{user.home}/.appName/foo

But if the app is ran on Windows, I'm not sure how that translates since .appName on *nix systems are hidden. What is the best practice for doing such things? Is there an API I am overlooking?
 
Joe Ess
Bartender
Posts: 9443
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a couple of apps that do exactly that. Gimp, JEdit, SmartCVS and others. All cross-platform and all use the "." filename convention in the home directory on XP. They aren't hidden directories on Windows, but it probably doesn't matter. Most Windows users go to their "My Documents" directory by default rather than their home directory.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:
I have a couple of apps that do exactly that. Gimp, JEdit, SmartCVS and others. All cross-platform and all use the "." filename convention in the home directory on XP. They aren't hidden directories on Windows, but it probably doesn't matter. Most Windows users go to their "My Documents" directory by default rather than their home directory.


I wondered that too. I have recently rebuilt my PC so I haven't got around to reinstalling everything so I didn't realize that those apps also use the DOT directories even in Windows.

Thanks.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
{user.home}\Application Data\appName\foo

That's the usual name. Application Data itself is hidden by default.

Because of this I've written a utility method:
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob. I would have expected Something like this to already be available in the Java API.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rob Prime:
{user.home}\Application Data\appName\foo

That's the usual name.


That's depends on the locale. On Windows, you should use the APPDATA environment variable, which in my case looks like

APPDATA=C:\Dokumente und Einstellungen\preuss\Anwendungsdaten
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah right, non-English versions of Windows...
Even though I'm not from an English speaking country, I always prefer my software to be English. Guess that has reflected to a piece of my code
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!