Starting tomcat server through Your java class
***********************************
We generally click TOMCAT_HOME\bin\tomcat7.exe to start the tomcat server
it internally executes org.apache.catalina.startup. Bootstrap.java
BootStrap.java is a class which contains main()
When we launch tomcat,jvm internally create the object of BootStrap.java and calls main() on it
Write your own Javaclass.From the main() of ur class,call the main() of BootStrap.class,server will start successfully
create the directory structure
*******************************
TomcatProj
|-->src
| |-->StartTomcat.java
|
|-->conf
| |-->Server.xml(copy & Paste it from TOMCAT_HOME\conf folder)
|
|----->lib
|--->bootstrap.jar --->main jar file, all others are dependent jar file
|--->tomcat-juli.jar
|--->catalina.jar
|--->servlet-api.jar
|--->jasper.jar
|--->jsp-api.jar
|--->tomcat-coyote.jar
|--->tomcat-util.jar
Collect first 2 jar from Tomcat_HOME\bin folder
and Remaining jars from TOMCAT_HOME\lib folder
jasper.jar,jsp-api.jar is needed to activate jsp support,other wise not needed
***************StartTomcat.java*****************
import org.apache.catalina.startup.Bootstrap;
public class StartTomcat
{
public static void main(String[] args) throws Exception
{
Bootstrap bs=new Bootstrap();
bs.main(args);
}
}
***************Program Ends***********************
***********************************
We generally click TOMCAT_HOME\bin\tomcat7.exe to start the tomcat server
it internally executes org.apache.catalina.startup. Bootstrap.java
BootStrap.java is a class which contains main()
When we launch tomcat,jvm internally create the object of BootStrap.java and calls main() on it
Write your own Javaclass.From the main() of ur class,call the main() of BootStrap.class,server will start successfully
create the directory structure
*******************************
TomcatProj
|-->src
| |-->StartTomcat.java
|
|-->conf
| |-->Server.xml(copy & Paste it from TOMCAT_HOME\conf folder)
|
|----->lib
|--->bootstrap.jar --->main jar file, all others are dependent jar file
|--->tomcat-juli.jar
|--->catalina.jar
|--->servlet-api.jar
|--->jasper.jar
|--->jsp-api.jar
|--->tomcat-coyote.jar
|--->tomcat-util.jar
Collect first 2 jar from Tomcat_HOME\bin folder
and Remaining jars from TOMCAT_HOME\lib folder
jasper.jar,jsp-api.jar is needed to activate jsp support,other wise not needed
***************StartTomcat.java*****************
import org.apache.catalina.startup.Bootstrap;
public class StartTomcat
{
public static void main(String[] args) throws Exception
{
Bootstrap bs=new Bootstrap();
bs.main(args);
}
}
***************Program Ends***********************
No comments:
Post a Comment