I need to restart my Tomcat server from Java code. I'm a beginner in Java. I try to do that by cmd. I need to stop tomcat then restart it. I try this code. It works with just two commands (one &&) and it doesn't work if I add a third command (two && in the line exec("cmd /c start cmd.exe ...)
).
PS: If another way exists to restart Tomcat with Java code please tell me
public class restart_tomcat {
public static void main(String[] args) throws SDKException, IOException {
Runtime rt = Runtime.getRuntime();
try {
// Process process1 = Runtime.getRuntime().exec("cmd /c start cmd.exe /K " + cmd1);
rt.exec("cmd /c start cmd.exe /K \"cd C:\\\\Program Files (x86)\\\\SAP BusinessObjects\\\\tomcat\\\\bin&&startup.bat\"");
System.out.println("succesful");
} catch (IOException e) {
e.printStackTrace();
}
}
}