Skip to Main Content

Java Programming

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!

Getting the absolute path of the current executing file

800295Jun 18 2007 — edited Jul 2 2008
I have a file which will be placed in window and linux environment. It is not good to change the source code in that way:
String path = "D:\\java\file1.txt"; (Window)
String path = "/java/file1.txt"; (Linux)

So I would like to ask how to get the absolute path based on that executing file?
I referred to the reference in jsp, but I don't know what class and the coding syntax in console environment.

Thx for any help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 30 2008
Added on Jun 18 2007
17 comments
831 views