0

I have an eclipse rcp application, which i am launching by setting the working directory in the arguments tab of the debug configuration.

Meanwhile i needed to change the current working directory upon application start.

I've tried the following options : System.setProperty("user.dir", this.strDestination);

But it doesn't work if we use relative file path, as it refers to the older working directory. Only solution that is working in this regard is using getAbsoluteFile or getAbsolutePath (which is not a feasible option as relative paths is used in a number of location).

Any approach in this regard is highly appreciated.

Vedant Agrawal
  • 65
  • 1
  • 2
  • 8

2 Answers2

0

I'm pretty sure you can't modify the current process' working directory. Instead you can use the File(String, String) constructor which creates a new File instance from a parent pathname string and a child pathname string.

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
0

Is your this.strDestination variable an absolute path?
According to this answer, you should use an absolute path in System.setProperty for the "user.dir" changes to take effect.

Note: I didn't have enough rep to add a comment. Hence adding as an answer.

Community
  • 1
  • 1
Codebender
  • 14,221
  • 7
  • 48
  • 85