JVM is Java Virtual Machine, a memory space where classes (code) are loaded and objects (data) are shared. JVM is equivalent to an Operating System process.
When you type
java...
in you command line you are executing an independent process that loads Java classes in memory, the base classes from Java and yours (from the .class files or .jar you indicate).
Another
java...
command will load a different process with its own memory and will load classes by itself.
Instance word confusion: when you say 'two instances of the same JVM'. It's usual to say instance of a JVM to a separate process, it is, to a loaded independent JVM. If you are saying: two process are running JVM 1.5, OK, it's the same JVM in the sense it's the same version but they are different processes, different 'instances', independent in all sense.
Webapp confusion: A webapp (by example) is simply a bunch of classes and objects instantiated, attending some URL in a web server. You can start Tomcat with 10 different apps -it is, 10 different bunches of classes and objects each of them attending different request, but in fact they share the same memory space (OS process). A webapp cannot touch other webapp's objects because nobody gives it a reference to the other objects (and classes are in some way hidden but that's another story called: class-loading). Tomcat runs in a single JVM, so every app deployed to a single tomcat instance runs in the same VM as every other application. They get different classloaders, so they're isolated from each other in that sense, but the JVM is the same. Tomcat uses a hierarchy of classloaders: bootstrap, server, and application. Every application gets their own classloader, but they share the higher ones
Comments
Post a Comment