Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

The foolproof way of finding application's directory(folder) ?

843810Jun 29 2010 — edited Jun 30 2010
Hi All,

What is the foolproof way of finding one's application's directory through code?

The property "user.dir" is no good as it returns different values for the same application without any change in the application's location. I found that on the first run of the application, it returns the correct directory path, but on the second or subsequent runs, it returns the path of a subdirectory of the application.

Same goes for the method - new File().getAbsolutePath()

I googled for it and found only the above two methods are mentioned in the forums where this question has been raised. Surely there must exist a more reliable way of finding one's application's path.

Thanks for any advice that you can offer.

Regards,
Dinesh Bajaj
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 28 2010
Added on Jun 29 2010
4 comments
109 views