I am using System.getProperty("user.dir") as the entry point (absolute path) in which any other file (and directory) traversal is relative with respect to the entry point.
The user.dir property has different values whether the program is invoked from the command line, or by the IDE (as expected).
What is the best practice to insure that the user.dir property will be “independent” in the execution environment?
Update: if you are using Eclipse for your IDE, check System.getProperty("user.dir") anomaly in Eclipse
The whole point of the
user.dirand similar properties is, that it is dependent on the execution environment.So the answer would be: don’t
What you can do though in eclipse is to edit the run configuration to use a working directory that fits your needs. This will be available in other IDEs as well I guess.