Changing the working directory


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Changing the working directory

  1. #1
    Jörg Eckart Guest

    Changing the working directory


    Hi all,

    I want to change the current directory to start commands with
    Runtime.exec() at a specified position. Starting the command
    with its full path name is not acceptable because of its
    arguments. I tried to set the property "user.dir" with
    System.get/setProperties(), but this has no effect. I am
    working with jdk1.1.8.

    Does anybody know how to change the working directory?

    Thanks in advance,

    Jörg


  2. #2
    Paul Clapham Guest

    Re: Changing the working directory

    You can't change the working directory. But try this (quote from Runtime's
    Javadoc):

    exec(String command, String[] envp, File dir)
    Executes the specified string command in a separate process with the
    specified environment and working directory.

    (You will probably want to use an empty string array for the second
    parameter.)

    Jörg Eckart <joerg.eckart@gmx.de> wrote in message
    news:39870cfd$1@news.devx.com...
    >
    > Hi all,
    >
    > I want to change the current directory to start commands with
    > Runtime.exec() at a specified position. Starting the command
    > with its full path name is not acceptable because of its
    > arguments. I tried to set the property "user.dir" with
    > System.get/setProperties(), but this has no effect. I am
    > working with jdk1.1.8.
    >
    > Does anybody know how to change the working directory?
    >
    > Thanks in advance,
    >
    > Jörg
    >




  3. #3
    Jo Desmet Guest

    Re: Changing the working directory

    The only best way *is* to use the full path for executing the command, maybe
    you can also use the full path for the parameters?
    Aside that you could also cd to that path by using a multiple command
    statement, which is different for both unix and dos. In does you will do
    something like this:
    cd mypath & mycommand
    the '&' will append two different commands.
    "Paul Clapham" <pclapham@core-mark.com> wrote in message
    news:398ae91b@news.devx.com...
    > You can't change the working directory. But try this (quote from

    Runtime's
    > Javadoc):
    >
    > exec(String command, String[] envp, File dir)
    > Executes the specified string command in a separate process with the
    > specified environment and working directory.
    >
    > (You will probably want to use an empty string array for the second
    > parameter.)
    >
    > Jörg Eckart <joerg.eckart@gmx.de> wrote in message
    > news:39870cfd$1@news.devx.com...
    > >
    > > Hi all,
    > >
    > > I want to change the current directory to start commands with
    > > Runtime.exec() at a specified position. Starting the command
    > > with its full path name is not acceptable because of its
    > > arguments. I tried to set the property "user.dir" with
    > > System.get/setProperties(), but this has no effect. I am
    > > working with jdk1.1.8.
    > >
    > > Does anybody know how to change the working directory?
    > >
    > > Thanks in advance,
    > >
    > > Jörg
    > >

    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center