Open In App
Related Articles

Java Program to Find Current Working Directory

Improve Article
Save Article
Like Article

The getproperty() methods defined in System Class in Java which is used to retrieve the value of the property named in the argument list. This method property is specified by the key which accepts the parameter. If the property does not exist, this version of getProperty returns null.

Syntax :

public static String getProperty(String key)

Parameter :

  • key: key whose system property we want

Returns :

  • System property as specified the key
  • Null: if there is no property present with that key.



// Java Program to Find 
// current working directory
public class GFG {
    public static void main(String[] args)
        // Getting the path of system property
        String path = System.getProperty("user.dir");
        // Printing the path of the working Directory
        System.out.println("Working Directory = " + path);


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 29 Oct, 2020
Like Article
Save Article
Similar Reads
Complete Tutorials