Re: Executing command with Runtime.getRuntime.exec() fails
- From: Ingo Menger <quetzalcotl@xxxxxxxxxxxxxx>
- Date: Thu, 29 Nov 2007 08:05:56 -0800 (PST)
On 29 Nov., 16:30, Nigel Wade <n...@xxxxxxxxxxxx> wrote:
Ingo Menger wrote:
On 29 Nov., 13:23, Lionel <lione...@xxxxxxxxx> wrote:
I did in fact try using exec(String[]) but perhaps I tokenized it
incorrectly. This is what I tried:
String mysqlServiceCommand[] = {"cmd", "/c",
"C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\mysqld-nt.exe\"",
"--install", "MySQL1",
"--defaults-file=\"C:\\Program Files\\MySQL\\MySQL Server " +
"5.0\\my-large.ini\""};
What is the "cmd /c" for, except to make the program less portable?
I think one can trust that Runtime.exec will choose the right command
interpreter.
No, it definitely will not.
I just read the API docs and find out to my surprise that you're
right.
I didn't also know that Runtime.exec indeed does tokenization which
makes things more, not less, complicated and does not make any sense,
IMHO.
exec() will run exactly what you tell it to run.
Sure. In this case
cmd /c C:\Program Files\... further args ...
If
you don't explicitly include cmd.exe then it will not run cmd.exe.
Too bad for the "run anywhere" approach. Especially when directory
names contain spaces.
.
- Follow-Ups:
- References:
- Executing command with Runtime.getRuntime.exec() fails
- From: Lionel
- Re: Executing command with Runtime.getRuntime.exec() fails
- From: Gordon Beaton
- Re: Executing command with Runtime.getRuntime.exec() fails
- From: Lionel
- Re: Executing command with Runtime.getRuntime.exec() fails
- From: Ingo Menger
- Re: Executing command with Runtime.getRuntime.exec() fails
- From: Nigel Wade
- Executing command with Runtime.getRuntime.exec() fails
- Prev by Date: Re: Array initialisation
- Next by Date: Re: Executing command with Runtime.getRuntime.exec() fails
- Previous by thread: Re: Executing command with Runtime.getRuntime.exec() fails
- Next by thread: Re: Executing command with Runtime.getRuntime.exec() fails
- Index(es):
Relevant Pages
|