text: how to use exec() command of java to launch a batch file (the syntax of using it)? how to use exec() command of java to launch a batch file (the syntax of using it). a piece of code will be usefull.  thanks in advance 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.