3

If I start a Java application on a physical machine and then I start a second Java application, a third application ... etc.

Is every time a new Java Virtual machine started. So that every app has it's own JVM?

Or is the memory allocated for the first JVM enlarged by the operating system of the physical machine and all apps run in one JVM? So that there will be always only one JVM.

cluster1
  • 4,968
  • 6
  • 32
  • 49
  • See this: http://stackoverflow.com/questions/20307500/how-many-java-virtual-machine-extst-on-computer?rq=1 – zed Feb 17 '17 at 09:51
  • See [here](http://stackoverflow.com/questions/5947207/is-there-one-jvm-per-java-application), same question has been asked before. – theasianpianist Feb 17 '17 at 09:51

3 Answers3

2

Actually when you "start an application", what you're doing is starting a new JVM and telling it to execute a class through the command line arguments.

However, in web applications executed inside a servlet container, each app will have it's own classloader, therefore they won't share the content of static variables. That could give you the impression that each runs on a different JVM.

Andres
  • 10,561
  • 4
  • 45
  • 63
2

JVM — instance of JRE. When you run application - new JVM is initialized. After application finished - the instance is removed by garbage collector.

Pavlo Plynko
  • 586
  • 9
  • 27
-1

Every time a new java application is started, a new instance of JVM is created. The application runs within this JVM instance.

Rob Audenaerde
  • 19,195
  • 10
  • 76
  • 121
Preetam
  • 1
  • 1