How to start and stop tomcat using java code?
You need to execute main
method of org.apache.catalina.startup.Bootstrap
with the parameter "start"
.
You also need following things:
tomcat/bin/bootstrap.jar
in your classpath;-Dcatalina.base
to point to $TOMCAT_HOME
-Dcatalina.home
to point to $TOMCAT_HOME
-Djava.io.tmpdir
to point to a temporary directory (usually $TOMCAT_HOME/temp
)I also have -noverify
parameter set, not sure if it is always necessary.
p.s. it would also be nice if you could start accepting answers, your current rate is 0/28.