Arne said:
Lew said:
Tsk. That's why there's the (String []) overload. The (String)
overload is only meant as a convenience for the simple case.
No.
exec(String) is a convenience method to execute programs
with no arguments.
exec(String[]) is a convenience method to execute programs
with arguments.
The convenience added is environment and default dir.
That is at variance with what the API says. The API places no restriction on
exec(String) executing programs with no arguments. What is says is:
"This is a convenience method. An invocation of the form exec(command, envp,
dir) behaves in exactly the same way as the invocation exec(cmdarray, envp,
dir), where cmdarray is an array of all the tokens in command.
More precisely, the command string is broken into tokens using a StringTokenizer
created by the call new StringTokenizer(command) with no further modification
of the character categories. The tokens produced by the tokenizer are then
placed in the new string array cmdarray, in the same order."
So exec(String) and exec(String[]) are semantically equal, the only difference
being that in exec(String) the string is broken up by the StringTokenizer and
in exec(String[]) the string is broken up by the programmer. You can use
exec(String) if StringTokenizer splits the string you pass correctly.
[Note: exec(String) is equivalent to exec(String,null,null)]
exec(String) may accept arguments on some platforms. It does
on Windows. Obviously because CreateProcess accept it. But SUN
could remove that in next release.
I don't see what you mean by this. I can't see anything in the documentation
which states any platform dependence on how exec(String) interprets the String,
or anything which Sun might remove in any future release.