1

Tomcat startup.bat is called with Process in the Java code, which will create a new CMD window, and the rest of my Java code will not execute.Do I need to start a new Thread to do this? but even then I still can't get the br.

Runtime runtime = Runtime.getRuntime();
Process process;
BufferedReader br = null;
try {
    process = runtime.exec(command);
    runtime.gc();
    String line = null;
    String content = "";
    br = new BufferedReader(new 
    InputStreamReader(process.getInputStream()));
    while ((line = br.readLine()) != null) {
        content += line + "\r\n";
    }
    System.out.println(content);
} catch (IOException e) {
        System.out.println(e);
} finally {
    if (br != null) {
        br.close();
    }
}
MLM520
  • 59
  • 2

1 Answers1

1

Tomcat's startup.bat invokes catalina.bat start, which always opens a new window.

Try catalina.bat run instead, which will start Tomcat in the current window.

More details can be found here and here.

rustyx
  • 80,671
  • 25
  • 200
  • 267