JDK-4483865 : RFE: No command to change the current working directory
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.3.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-07-25
  • Updated: 2001-07-25
  • Resolved: 2001-07-25
Related Reports
Duplicate :  
Relates :  

Name: rmT116609			Date: 07/24/2001

java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

There is simply no way for one to programmatically change the current
working directory.

If I invoke my application from c:\my_directory\, I am stuck in that
directory.  Every file that my application opens or creates must
either be specified absolutely or must be accessible relative to
this directory.

In addition, if I want to use Java Reflection to invoke another Java
application without spawning another JVM (to save memory), I need a
way to change the CWD to the directory of the application to be spawned.


    Class  extClass = Class.forName("ext.MyApplication");
    Class  argv[]  = { new String[0].getClass() };
    Method extMain  = extClass.getMethod("main", argv);

    // Invoke vqServer web server!
    extMain.invoke(null, new Object [] { args });

The problem is that the enclosing class is not guaranteed (and cannot
be forced) to start in the home directory of ext.MyApplication.
(Review ID: 128736)