michelemarcon michelemarcon - 1 year ago 114
Java Question

How to get a Windows virtual folder location from Java?

I'd like to retrieve the location of a Windows virtual folder from Java. JNA provides some support but the documentation don't explain how to directly use it.

Answer Source

Having a look into the JNA source reveals the javadoc of Shell32Util.getKnownFolderPath(Guid.GUID)

Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID.

The local application data directory can be retrieved as

String localAppDataDir = Shell32Util.getKnownFolderPath(

output will be something like


where JohnDoe is the name of the current user.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download