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!

Problem running app outside it's directory

807569Jul 6 2006 — edited Jul 6 2006
Hi
I wrote an application that uses System.getProperty("user.dir") to get the path to it's directory. I need it to read certain files on app startup, and also save configuration (everything in the program directory).

Now as it turns out I cannot start the application outside it's directory. Under Windows links work ok so it's not a problem, but on linux running the app thru a symbolic/hard link when I am not in the application directory is not possible.

Also under windows I wanted to associate my app with a certain file type. Everything works ok when I run it from inside the application directory and give a full path to the file I want to open (myapp F:\somedir\file), but when I go to the file directory (F:\somedir\ - which is not where I have my application) and try to open it with my app - my app just crashes, sort of like on Linux when using links. It also creates certain files there (in F:\somedir\ for this example) that should be created in the program directory.

Is there anyway I can get around this (and not make my application less cross-platform)?

Thanks in advance
mike
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 3 2006
Added on Jul 6 2006
4 comments
153 views