How to run a batch file/native application from Java?
Created May 4, 2012
Iryna Issayeva
Use Runtime.exec(String pathToBatchFile).
Here is the sample from my code.
void runServer() { String str = null; String cmdServer="E:/Server/server.bat"; Runtime run = Runtime.getRuntime(); Process process = null; try { process = run.exec(cmdServer); BufferedReader br = new BufferedReader( new InputStreamReader(process.getInputStream())); while ( null != ( str = br.readLine() ) ) System.out.println( str ); br.close(); } catch( java.io.IOException e ) { System.out.println( "Error while executing the process : " + e ); } }