/** * (C) Copyright Sheldon Bradley Wosnick, April 2000 - All Rights Reserved. * * DISCLAIMER: * The following [enclosed] code is sample code not created by IBM * Corporation. This sample code is not part of any standard IBM product * and is provided to you solely for the purpose of assisting you in the * development of your applications. The code is provided 'AS IS', * without warranty of any kind. IBM shall not be liable for any damages * arising out of your use of the sample code, even if they have been * advised of the possibility of such damages. */ public class StopTomcat { public static void main(java.lang.String[] args) { try { Class aClass = Class.forName("org.apache.tomcat.startup.Tomcat"); java.lang.reflect.Method method = null; Class[] argsClass = new Class[] {String[].class}; // get the main method for the org.apache.tomcat.startup.Tomcat class method = aClass.getMethod("main", argsClass); Object object = null; Object[] arguments = new Object[] {new String[] {"-stop"}}; // now invoke the main method for the org.apache.tomcat.startup.Tomcat class method.invoke(object, arguments); } catch (Exception e) { System.out.println("Exception occurred: " + e.getMessage()); e.printStackTrace(); } } }