Edy1988
asked on
How to send Windows path (With spaces) as parameters to Runtime.exec with Java 1.5?
Hi,
In Java 1.4 when I needed to send to Runtime.exec a parameter with spaces (Path under 'Program Files') I would just wrap it with:
String quotes= "\"";
and put quotes before and after it.
In Java 1.5 it adds to the string \" and not just " as I wanted, so how do I add " at the beginning and at the end?
Thanks
Eyal
In Java 1.4 when I needed to send to Runtime.exec a parameter with spaces (Path under 'Program Files') I would just wrap it with:
String quotes= "\"";
and put quotes before and after it.
In Java 1.5 it adds to the string \" and not just " as I wanted, so how do I add " at the beginning and at the end?
Thanks
Eyal
What is the path
You would generally use something like
path = "\"C:\\Program Files\\Something\\Somethin g.exe\"";
path = "\"C:\\Program Files\\Something\\Somethin
ASKER
C:\Program Files\....
ASKER
This path also crash, you need to have:
""C:\\Program Files\\Something\\Somethin g.exe" -version", no?
""C:\\Program Files\\Something\\Somethin
If there are parameters then it would be
path = "\"C:\\Program Files\\Something\\Somethin g.exe -version\"";
path = "\"C:\\Program Files\\Something\\Somethin
You'd be better off doing it more like this though:
List<String> args = new ArrayList<String>(2);
args.add("C:\\Program Files\\Something\\Somethin g.exe");
args.add("-version");
ProcessBuilder pb = new ProcessBuilder(args);
List<String> args = new ArrayList<String>(2);
args.add("C:\\Program Files\\Something\\Somethin
args.add("-version");
ProcessBuilder pb = new ProcessBuilder(args);
ASKER
Tryed the path = "\"C:\\Program Files\\Something\\Somethin g.exe -version\"";
It still cuts the path after the C:\Program
Any ideas?
It still cuts the path after the C:\Program
Any ideas?
you probably need to \ the spaces too?
also, try adding file:/
"file:/C:\\gen\\currency\\ ";
"file:/C:\\gen\\currency\\
ASKER
Hi,
The problem was the parameters "cmd.exe /C" before the command, now it works.
Thanks
The problem was the parameters "cmd.exe /C" before the command, now it works.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.