How do I set the current working directory to a particular directory, such that subsequent file opens only need to only use relative file paths?
Location: http://www.jguru.com/faq/view.jsp?EID=203366 Created: Sep 12, 2000 Modified: 2001-08-18 18:59:20.029 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by Charles Chen (http://www.jguru.com/guru/viewbio.jsp?EID=137374 I seem to recall a time where setting the user.dir System property did this for you. However, that doesn’t seem to work any more (if it ever did). There is no standard way to do this, like a method of the File class or some such. The best you can do is to create a File object for the new “root” directory, then create new File objects passing this as the parameter to it: File root = new File(“/foo/bar”); File real = new File(root, “real”); Also, according to David Rees: Note that setting the “user.dir” in Java doesn’t change the working directory – it only seems to ;). All it really does is update the path that the methods getAbsolute* and getCanonical* work relative to. For instance if you start a program in Java in the