You can get the current working directory for the JVM by reading the user.dir system property.
String workingDir = System.getProperty("user.dir");
public class Main { public static void main(String[] args) throws Exception { String workingDir = System.getProperty("user.dir"); System.out.println(workingDir); }// w w w . ja va 2s .co m }
To specify the current working directory for the JVM as the user.dir property value as a JVM option.
java -Duser.dir=C:\test your-java-class