×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / A java question about starting batch file via Runtime.exec.
    I met a question below:

    I must start a service(jettyHttpserver) or a batch file via java. I use runtime.exec("cmd.exe /c a.bat ") or runtime.exec("cmd.exe /c psservice.exe start jettyHttpserver").But they donot work.In command line,It all work well. Who can tell me the reason?Thanks in advance!
    • try it. have fun!
      import java.io.*;
      import java.util.*;

      public class testExec{
      public static void main(String args[]){
      Runtime rt = Runtime.getRuntime();
      try {
      rt.exec("notepad.exe");
      }catch(Exception e){
      System.out.println(e);
      }
      }
      }