How can I change the current working directory from within a Java program? Everything I\'ve been able to find about the issue claims that you simply can\'t do it, but I can\
The smarter/easier thing to do here is to just change your code so that instead of opening the file assuming that it exists in the current working directory (I assume you are doing something like new File("blah.txt")
, just build the path to the file yourself.
Let the user pass in the base directory, read it from a config file, fall back to user.dir
if the other properties can't be found, etc. But it's a whole lot easier to improve the logic in your program than it is to change how environment variables work.