Explore Java

Be Social. Be Updated.

  • Stumble
  •   
  •   

Get Windows Directory in Java



A single line of code to get Windows (System directory) of your PC folder path in Java.


Get Windows Directory



class GetWindowsDir
{
public static void main(String args[])
{
System.out.println(System.getenv("windir"));
}
}



System.getenv(): Takes a property name and returns its value. env means environment.

windir: Represents the windows (system directory). Ex: C:\Windows (provided if you install your OS in C)

Sample Output



C:\Windows

Also see my other posts on Getting Java Installation Folder in Java and also Get Operating System name in Java

0 comments:

About This Blog

This blog contains Java Tutorials, Code Samples,demonstrating several concepts in Java. All the code samples are well tested by a team of experts and hence there will be no programmatical errors. We are seamlessly thriving in making the tutorials easier for beginners.

About the Author

was a software and technology enthusiast. He is a 12th grade student and a part time blogger with extreme love in Java programming.Follow him on Google+ and Twitter or befriend him on Facebook and also on