How can we code in java to find out the drive letter on which operating system is installed ?
Asked
Active
Viewed 3,551 times
2
-
7Are you aware that there are operating systems that do not follow the "Windows Drive Letter Concept"? Is this supposed to work on Windows only? – reto Feb 24 '14 at 10:30
-
Yes, i am looking it for windows only. – FullStack Feb 24 '14 at 10:31
-
2@reto not really a duplicate because it uses the win32 api. Can't be called as is from java, you would need a JNI call. – assylias Feb 24 '14 at 10:33
-
@assylias you do have a point there, the most voted answer is however referring to the same system env. variable – reto Feb 24 '14 at 10:37
-
1Once upon a time the operating system used to be on the A: drive but that was long before windows. Do you ever see users installing on a drive other than C: ? – Peter Lawrey Feb 24 '14 at 10:50
1 Answers
10
You can get that from the Environment:
System.getenv("SystemDrive");

user432
- 3,506
- 17
- 24
-
it is not work for me, it is not standard environment variable in Linux; – M2E67 Nov 24 '18 at 15:07