JDK-4129773 : Runtime.exec() can't set the working directory
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.1.5
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1998-04-16
  • Updated: 1998-07-19
  • Resolved: 1998-07-19
Related Reports
Duplicate :  
Description

Name: dm26566			Date: 04/16/98


It is impossible to write a application launcher
in 100% pure java.  Many external programs
require the current working directory to be
set to something specific.  Currently, the only
way to accomplish is to create a proprietary
native library.

Java should have a function such as:
Runtime.exec(String cmd[], String env[], File cwd)
which uses cwd as the working directory for the 
new process.
(Review ID: 28456)
======================================================================
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


======================================================================

Comments
WORK AROUND Name: dm26566 Date: 04/16/98 Must write a new library using native methods. ======================================================================
11-06-2004