You should do three things differently compared to working code that I have, this may or may not solve your actual problem:
1) You should not pass cmd
, with Runtime.getRuntime().exec()
you are essentially in the commandline interface already.
2) You should enclose every argument with spaces within quotes, so in Java it looks like the following: "\"argument with spaces\""
.
3) There may only be one argument in each element, in this case in String[]
.
In your code you may do it like this:
p = Runtime.getRuntime().exec(new String[]{
"\"C:/OpenOffice 4/program/python.exe\"",
"\"C:/OpenOffice 4/program/DocumentConverter.py\"",
"\"C:/OpenOffice 4/program/a.odt\"",
"\"C:/OpenOffice 4/program/b.pdf\""});
Then at a later point you can call p.waitFor()
if you want your thread (program) to waiit until the execution has finished.