I'm not a java programmer, but this is what I came up with:
import java.util.*;
import java.io.*;
public class EXECBATCH
{
public static void main(String args[])
{
try
{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("YOURBATCHFILEGOESHERE");
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
System.out.println("
");
while ( (line = br.readLine()) != null)
System.out.println(line);
System.out.println("");
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
} catch (Throwable t)
{
t.printStackTrace();
}
}
}
There appear to be a number of potential "pitfalls" with using
the exec command.
Depending on what your batch file does, you might run into some of them.
I've linked to an article (where I got the above code from) which discusses them, and their workarounds.