Explore Java Hacks and Tutorials
Be Social. Be Updated.

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.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


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

Posted by at on

Tags: java.lang System Properties