I have an exe file which takes a file name as input.
When I execute it as a command like:
xyz.exe c:\input.txt c:\ouput.txt
It all works as expected.
But how to execute this is java?
This is the one i used and am not getting the ouput in the files:
String[] str = {"c:/input.txt","c:/output.txt"};
Process p = rt.exec("c:/xyz.exe",str);
You’re using the method:
where
envpis a (quote) “array of strings, each element of which has environment variable settings in the format name=value, or null if the subprocess should inherit the environment of the current process.”Try this instead:
Also read this article that explains the pitfalls of
Runtime.exec(...): http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html