-
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
-
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
>
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks