4

I once found a nifty little library that used JNI to allow java applications on Windows to get the locations of various "special" directories on windows. I can't for the life of me find it again...

In particular, I need to get the location of the "All Users" (shared) "Application Data" directory.

So, anyone have a bullet proof way in Java to locate the "All Users" "Application Data" folder?

It needs to be bullet proof.

Eric
  • 95,302
  • 53
  • 242
  • 374
SvrGuy
  • 376
  • 4
  • 11
  • The bulletproof way to do this the Windows API SHGetKnownFolderPath http://msdn.microsoft.com/en-us/library/bb762188%28v=VS.85%29.aspx but I don't know an easy way to call that from Java. – Rup Jul 29 '10 at 08:49
  • JNA comes with a fairly complete set of standard API bindings, maybe that's what you mean? https://github.com/twall/jna – millimoose Sep 01 '13 at 22:30

2 Answers2

1

You might want to research Environment Variables:

http://en.wikipedia.org/wiki/Environment_variable#DOS_and_Windows http://en.wikipedia.org/wiki/Environment_variable#System_path_variables

The System.getenv() method offers a list of the system's environment variables and it's included in the core library. Doesn't get much more bullet-proof than that.

Nitrodist
  • 1,585
  • 5
  • 24
  • 34
-2

You could use the following property in the environment:
ALLUSERSPROFILE=C:\Documents and Settings\All Users

Edit: This no longer works as of Windows Vista and newer.

Romain Hippeau
  • 24,113
  • 5
  • 60
  • 79