Get User Home Directory in Java

Tags: System

In this Java core tutorial, we learn how to get the user home directory in the Java program.

How to use System.getProperty() static method to get user home directory

GetUserHome.java

public class GetUserHome {
    public static void main(String[] args) {
        String userHomeDirectory = System.getProperty("user.home");

        System.out.println("User Home Directory: " + userHomeDirectory);
    }
}
The output is:
User Home Directory: C:\Users\SimpleS

Get Operating System Name in Java

Get Java Version