JDK-4081777 : (process) RFE: Would like to be able to set CWD for Runtime.exec'd() command
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.1.3,1.1.5
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_2.5.1
  • CPU: generic
  • Submitted: 1997-09-25
  • Updated: 1999-09-14
  • Resolved: 1999-09-14
Related Reports
Duplicate :  
Duplicate :  
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. 

WORK AROUND Use Runtime.exec() to call a "wrapper" (script or bat file) which does a cd to the desired directory and then executes the program.

SUGGESTED FIX Copied from 4129773:- ====================================================================== phil.race@eng 1998-04-17 An API call like public Process exec(String cmdarray[], String envp[], 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 ======================================================================

EVALUATION This should be solved by new exec() spec. ###@###.### 1999-09-13