Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get local application data folder in Java? [duplicate]

Possible Duplicate:
What is the cross-platform way of obtaining the path to the local application data directory?

I'm looking for a way to get the location of the local application data folder, which is a special Windows folder, in Java. Unfortunately, the following only works for English versions of Windows XP with default settings:

System.getProperty("user.home") + "\\Local Settings\\Application Data"

What I'd like to have is something like this in .NET:

System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

Is there a way to do it without having to call SHGetSpecialFolderLocation of the Windows Shell API?

like image 978
smf68 Avatar asked Jul 29 '09 09:07

smf68


People also ask

How do I get to AppData local?

To open the AppData folder on Windows 10, 8 & 7: Open File Explorer/Windows Explorer. Type %AppData% into the address bar and hit enter. Navigate to the required folder (Roaming or Local)

Where is local app data in Windows?

Select File Explorer Options. Select the View tab of the File Explorer Options window. Choose Show hidden files, folders, and drives > Apply > OK. The AppData folder is located at C:\users\YOURNAME, where YOURNAME is your Windows profile ID.

What is app data folder?

The application data folder is a special hidden folder that your app can use to store application-specific data, such as configuration files. The application data folder is automatically created when you attempt to create a file in it. Use this folder to store any files that the user shouldn't directly interact with.


2 Answers

System.getenv("APPDATA")

(there seems to be no env variable for the "Local Settings" folder, but this will give you the 'Application Data' folder)

like image 140
Ryan Fernandes Avatar answered Oct 31 '22 17:10

Ryan Fernandes


what about the following

String dataFolder = System.getenv("LOCALAPPDATA");

I have a situation where this is NOT under "user.home"

like image 20
Charles Godwin Avatar answered Oct 31 '22 17:10

Charles Godwin