0

They could be many JVMs per Operative system or it is only one JVM per Operative System ? I also read that with "Runtime.exit()", we stop the execution of a JVM?

I'm a bit confuse because I've always thought that JVM is a machine that never stop working, always awaken waiting to be called for example by the "java App.class".

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
  • 3
    related question : [Is there one jvm per java application ?](http://stackoverflow.com/questions/5947207/is-there-one-jvm-per-java-application) – NiziL Sep 23 '15 at 14:27
  • Also, you would never say `java App.class`. It's always `java App`; the JRE adds the .class – Elliott Frisch Sep 23 '15 at 20:52

4 Answers4

0

The JVM is an abstract concept, and there may be many running instances per Operating System. The implementation is usually through the Java Runtime Environment. And when exit is called, the runtime stops. The JVM can certainly stop. And (on most computers) it has to be explicitly started.

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
0

i'have always thougth that JVM is a machine that never stop working, always awaken waiting to be called for example by the "java App.class"

No, that is not how the JVM works. It's not a background process that is waiting to execute your Java programs. There is not always just one JVM running on one computer.

Whenever you start a Java program, a new JVM is started. When you have multiple Java programs running at the same time, you have multiple JVMs running. Each program is running in its own JVM.

System.exit() stops the JVM that is running the current Java application. It has no effect on other Java programs running on the same machine.

Jesper
  • 202,709
  • 46
  • 318
  • 350
0

If you start a java app (directly or indirectly with the java shell command), then an instance of the JVM is created and started.

When the application finishes (either by reaching the end or through System.exit() then the JVM instance stops.

Of course, you can have multiple Java apps running simultaneously. Each will be in its own JVM instance.

NickJ
  • 9,380
  • 9
  • 51
  • 74
0

They could be many JVMs per Operative system or it is only one JVM per Operative System ?

You can do either. You can run a JVM for each command, or you can use an application server to run your java applications. (You cna have more than one application server)

I also read that with "Runtime.exit()", we stop the execution of a JVM ?

This triggers the JVM to shutdown. The process does some work such as calling Shutdown Hooks after this is called.

i' m a bit confuse because i'have always thougth that JVM is a machine that never stop working,

It can be used that way. For example scala has a daemon compiler which is used to compile scala programs.

always awaken waiting to be called for example by the "java App.class".

When you run any program, (java or not) this always starts a new program. The only time this doesn't happen is for built in shell commands. e.g. set

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130