Minhas Kamal Minhas Kamal - 4 months ago 13
Java Question

Java: Using Relative Directory Path on Windows

Is there any way to get relative path in Java for Windows, something like the Environment Variables-

%systemdrive%
,
%appdata%
or
%temp%
?

Like in C using
windows.h
we can do this-

char* appdataFolderPath = getenv("APPDATA");





Edit: I have tried this solution. But it does not work!

Answer

You can use method System.getenv. Here is how you do it:

final String value = System.getenv("APPDATA");