Possible Duplicate:
Java execute a command with a space in the pathname
I am having following command
i_view32.exe C:\*.bmp /import_pal=C:\default.pal /convert=D:\temp\*.bmp
Which when i run through command prompt works fine.
I am trying to run the same command with the help of java.
Process p = Runtime.getRuntime().exec(System.getenv("ProgramFiles")+"\\IrfanView\\i_view32.exe c:\\*.bmp /import_pal= 1.pal /convert=d:\\temp\\*.bmp");
But i am not able to get Output in d:\\temp\\ Folder. Can any one suggest me where i am wrong.
Thanks in Advance..
Is there any other way to give "/" as i am using slash /import_pal=
2 your attempts are not exactly the same. I think that you executed command from command prompt when you were in
c:\Program Files\IrfanView. When you are trying to run the same command from java you mention the full path. Since some programs are sensitive to current working directory I’d recommend you first to try to run the command from other directory (e.g. from c:) but specify full path.If it works manually but does not work from java try to use ProcessBuilder instead of
Runtime.exec(). Actually it is almost the same but it more Object Oriented and allows to specify working directory separately. I hope this will work for you.If not try to play with quotes. Directory path ‘c:\Program Files’ contains space, so the path should be quoted.
Good luck.