I am trying to run an external program from a Java program and am having problems. Basically, I would like to do the following:
Runtime.getRuntime().exec("./extprogram <fileIn >fileOut");
However, I found that this will not work - Java apparently needs to use Process with input and output streams and other things that I do not encounter.
I looked at a number of examples on the Internet (many of which relate to SO), and there seems to be no simple standard way to do this, which for those who do not quite understand what is happening can be quite unpleasant.
I also had problems trying to create my own code with other people's code examples, because, as a rule, most other people 1. are not interested in redirecting stdin , but 2. do not necessarily redirect stdout to a file, and instead System.out .
So, can anyone point me towards any good simple code templates for calling external programs and redirecting stdin and stdout ? Thanks.
Matts source share