Greenhorn
Greenhorn

Reputation: 328

Tomcat and VM

I really confused in understanding where the tomcat actually runs. Is it execute inside the JVM, which execute servlets. Or it has it's own VM in executing servlet or JSP.

Thanks in advance.

Upvotes: 3

Views: 1066

Answers (4)

Vinnie
Vinnie

Reputation: 12730

This is a confusing subject as the "appearance of" separate JVMs is sometimes confused with different class loader instances.

Tomcat and your applications (WARs or servlets) share the same JVM, but they utilize independent class loaders - which is why you can have 2 WARs using different versions of something like log4J and all is good. Here's an article from O'Reilly about the class loader.

Upvotes: 3

lud0h
lud0h

Reputation: 2390

Java provides the JVM to run any Java application.

Tomcat is essentially a Java program which implements the Servlet container specification and acts as a Servlet Container.

It also means you need (atleast) the Java JRE to run Tomcat.

Upvotes: 3

Cogsy
Cogsy

Reputation: 5642

Tomcat and it's servlets all run inside a JVM.

Upvotes: 0

Brian Agnew
Brian Agnew

Reputation: 272387

Tomcat will run within the JVM, and servlets execute within the Tomcat process (in the same JVM).

Running catalina.sh (or .bat) will start up a new JVM for Tomcat to run in. You can load/run Tomcat programatically within an existing JVM if you require a webserver as part of a bigger application.

Upvotes: 13

Related Questions