import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
public class StartTomcat {
public static void main(String[] args) {
startTomcat();
}
public static void startTomcat() {
Runtime r = Runtime.getRuntime();
try {
Process p = r.exec("cmd /c D:\\apache-tomcat-7.0.52\\bin\\startup.bat", null, new File("D:\\apache-tomcat-7.0.52"));
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream(), "gbk"));
String str = "";
while ((str = br.readLine()) != null) {
System.out.println(str);
}
if (br != null) {
br.close();
}
if (r != null) {
r.gc();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
转载于:https://my.oschina.net/ydsakyclguozi/blog/264169