https://stackoverflow.com/questions/5256002/how-to-start-and-stop-tomcat-using-java-code

public class ApagarTomcat {

    public static void main(String[] args) {
        try {
            Socket socket = new Socket("localhost", 9005);
            if (socket.isConnected()) {
                PrintWriter pw = new PrintWriter(socket.getOutputStream(), true);
                pw.println("SHUTDOWN");//send shut down command 
                pw.close();
                socket.close();
                System.out.println("Apagado exitoso");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

 

Deja un comentario