Java System property set current working directory

Description

Java System property set current working directory

java -Duser.dir=C:\test\your-java-class

or 

System.setProperty("user.dir", "C:\\myDir");

To get the user directory:

public class Main {
  public static void main(String[] args) throws Exception {
    String workingDir = System.getProperty("user.dir");
    System.out.println(workingDir);
  }
}



PreviousNext

Related