1

Hi, I have a big problem. I'm making a java program and I have to call an exe file in a folder that have whitespace. This program also has 2 arguments that always have whitspace in the path. Example:

C:\Users\Program File\convert image\convert.exe C:\users\image exe\image.jpeg C:\Users\out put\out.bmp

I have to do this in Windows but i want generalize it for every OS.

My code is:

Runtime run = Runtime.getRuntime();<br/>
String path_current = System.getProperty("user.dir");<br/>
String [] uno = new String[]{"cmd","/c",path_current+"\\\convert\\\convert.exe",path_current+"\\\f.jpeg", path_current+"\\\fr.bmp"};<br/>
Process proc2 = run.exec(uno);<br/>
proc2.waitFor();<br/>

This does not work. I tried removing the String array and inserting a simple String with "\"" before and after the path but that didn't work. How do I resolve this?

keyser
  • 18,829
  • 16
  • 59
  • 101

2 Answers2

1

Remove "cmd" and "/c", and use a single forward slash instead of your triple backslaches.

Jerome
  • 8,427
  • 2
  • 32
  • 41