在jsp中怎样启动和关闭tomcat服务器
发布网友
发布时间:2022-04-06 08:38
我来回答
共1个回答
热心网友
时间:2022-04-06 10:07
//调用cmd启动tomcat 关闭则是shutdown.bat,需配置好tomcat和java的环境变量。
String path = "D:\\apache-tomcat-7.0.35\\bin\\startup.bat";
Runtime run = Runtime.getRuntime();
try {
// run.exec("cmd /k shutdown -s -t 3600");
Process process = run.exec("cmd.exe /k start " + path);
InputStream in = process.getInputStream();
while (in.read() != -1) {
System.out.println(in.read());
}
in.close();
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
}