|
-
Jan 14th, 2010, 10:08 PM
#1
Thread Starter
Fanatic Member
C# Application.StartupPath in Java
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
-
Jan 22nd, 2010, 04:13 PM
#2
Re: C# Application.StartupPath in Java
Code:
// To get the startup path
String dirPath = System.getProperty("user.dir");
// To do stuff with the path
File startupPath = new File(dirPath);
-
Jan 22nd, 2010, 06:13 PM
#3
Re: C# Application.StartupPath in Java
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
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|