I have a customer who has expressed desire to be able to set the current
working directory for commands executed via the Runtime.exec(). Commands
executed this way inherit the CWD from the java virtual machine.
Use Runtime.exec() to call a "wrapper" (script or bat file) which does a cd
to the desired directory and then executes the program.
Copied from 4129773:-
An API call like
public Process exec(String cmdarray,
File directory) throws IOException, FileNotFoundException
would be pretty easy to implement I think
On Solaris this can be implemented by doing a chdir() after the fork()
and before the exec()
On win32 the CreateProcess() system call takes an optional parameter
to set the working directory.
Implementing this would probably answer the needs of at least some
of the requestors of the more contentiosu RFE 4045688
This should be solved by new exec() spec.