I have a .exe
file, It takes .txt
file as a Input and it returns .txt
files as outputs.
I have 2 folders names are Inpu
For running an external process (a .exe
program in this case), forget about Runtime.exec()
. Instead use ProcessBuilder; the documentation states that it's the preferred way to start up a sub-process these days.
Follow this quick tutorial over running .exe from java. It should be sufficient (4pages)
http://www.javaworld.com/jw-12-2000/jw-1229-traps.html?page=1
example
import java.util.*;
import java.io.*;
public class GoodWindowsExec
{
public static void main(String args[])
{
try
{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("cmd.exe /C ping"); // executing ping through commandshell of windows
proc.getErrorStream() // errorstream
proc.getInputStream() // outputstream
int exitVal = proc.waitFor(); // wait till process ends
} catch (Throwable t)
{
t.printStackTrace();
}
}
}