4

Whenever we start a Java program:

java Herpyl.java -derp

Is this creating another JVM instance, or another Java process on top of the same JVM instance? I'm confused as to the relationship between JVM and "Java" or a "Java process". Thanks in advance!

2 Answers 2

8

Each java invocation starts its own JVM.

Sharing one JVM between processes has problems wrt security and stability: If one process kills the JVM you also killed the other and the other process really shouldn't be able to read/modify the data of the other process without the right rights (don't forget you can call arbitrary JNI code from your java process).

If you're worried about memory consumption: Yes that does indeed increase the memory, but any modern OS will map different dlls and other things - on my win7 x64 machine an idle javaw process has a private workingset of ~300kb.

Sign up to request clarification or add additional context in comments.

Comments

2

Acording to Oracle documentation:

The java tool launches a Java application. It does this by starting a Java runtime environment, loading a specified class, and invoking that class's main method

And the Java Runtime Environment includes the Java Virtual Machine and other components (like libraries) required to execute Java Applications.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.