// Getting the CWD: Current Wording Directory // namely the current directory when java.exe was invoked. // It cannot be changed on the fly. final String cwd = new File( "." ).getCanonicalPath(); // Which may or may not be the same as: final String userDir = System.getProperty( "user.dir" );You can, of course, spawn a script to a command shell that would be able change the CWD inside itself, but not for the spawning Java app.
You can fake a CWD by maintaining your own CWD variable and expanding all relative filenames to absolute yourself.
The catch is, a Java program cannot dynamically change the CWD. The closest it could to that is spawn command scripts with embedded CD commands, that change on the local CWD within the script. It is odd that code implementing scripts can change the CWD, but not Java. I gather Java’s designers figured that you could not could on every possible OS (Operating System) permitting you to change the CWD. They could not thus safely built it in as a WORA (Write Once, Run Anywhere) feature.
This page is posted |
http://mindprod.com/jgloss/cwd.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\cwd.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[13.59.92.247] |
| |
Feedback |
You are visitor number | |