Reputation: 869
I have a Java application which I call from the command prompt like this:
C:\Mydir> C:\dir2\my.exe
When I call this application I would like to retrieve at the same time the path "C:\MyDir", i.e. the active directory from where my exe is called in the prompt and not "C:\dir2\" where the exe is found.
How could I do that in Java?
Upvotes: 2
Views: 2875
Reputation: 1831
File f = new File("");
System.out.println(f.getAbsolutePath());
Upvotes: 1
Reputation: 1922
I believe you would use
String currentLocation = System.getProperty("user.dir");
Upvotes: 2