Reputation: 5068
In the following example, what is the difference between the two methods used to call "php hello.php" in Java? p1 vs p2?
String[] commands;
String command = "php hello.php";
commands[0] = "php";
commands[1] = "hello.php";
Process p1 = Runtime.getRuntime().exec(command);
Process p2 = Runtime.getRuntime().exec(commands);
Thanks!
Upvotes: 0
Views: 99
Reputation: 272257
In your particular scenario, none.
The multi-args version doesn't require the command line to be split up into arguments, and consequently it's provided for command-line arguments with spaces/tabs etc.
From the Javadoc for the first (convenience) method:
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
(it's actually the version taking the environment too, but will get delegated to)
Upvotes: 1