Hello All,
in C#, I able to get current application running path using:
String appPath Application.StartupPath;
how about in Java?
please help
thanks & regards
Printable View
Hello All,
in C#, I able to get current application running path using:
String appPath Application.StartupPath;
how about in Java?
please help
thanks & regards
Code:// To get the startup path
String dirPath = System.getProperty("user.dir");
// To do stuff with the path
File startupPath = new File(dirPath);
The property "user.dir" is User's current working directory which is not in anyway the application path. Simply because there are no applications in Java, there are classes and jar files (Still classes but the path is not usable) for example if you create a class called "Test" and tried running it from another location in the Command Prompt the user.dir property is that location you are at when running the class. If this is not clear, lets say Test.class is in C:\Test while the command prompt current dir is C:\Windows. You can run Test from Windows if you add it to the classpath "java -cp C:\Test Test and the user.dir property will return C:\Windows. Try it