I have an external program Otter that gets as parameter some filename and creates an output file, also specified as parameter.
So for example if my input is “proof.in” and I want my output to be placed in the “proof.out” file, I run the following command in the terminal:
otter <proof.in >proof.out
The “proof.in” file must be in the same file as the otter executable.
The problem is that I need this functionality from Java so in my Java code I do the following:
java.lang.Runtime.getRuntime().exec("otter <proof.in >proof.out")
but after this line the whole UI is frozen and nothing happens and no output file is generated.
Could anyone show me where I got it wrong??
Thanks in advance,
Tamash
This is normal: you are attempting to launch a command normally issued by a shell.
Here,
<proof.inand>proof.outare taken as literal arguments to theotterexecutable, and not shell redirections. But seeing the home page for this tool, it will not work: it expects data on stdin, which the redirect normally provides.You need to launch this command via a shell, and preferably using a process builder:
etc etc.
You should also ensure, of course, that the program runs from the correct directory — fortunately,
ProcessBuilderalso allows you to do that.