8

This question may be very basic about Java JVM. If I've a Java standalone program and if, for example, 5 processes of this program are running at a particular time in the server, can we say that these 5 java processes are running in 5 JVMs?

By process, I mean the Linux process here. If I execute ps -ef |grep java, I'll see 5 java processes showing up.

1

3 Answers 3

12

Yes, that's correct. There is one JVM per java process.

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

2 Comments

Can we say # of java processes equals # of JVMs running at all cases?
In a normal Linux setup, as described in your question. There are possible solutions for attempting more than one JVM per process. See this (old) article, for instance.
5

You can run the jps command (from the bin folder of JDK if it is not in your path) to find out what java processes (JVMs) are running on your machine.

2 Comments

@Gnanam : You will find the jps command useful in another situation. It is normally used to find out the process id of your java process, which can be passed to an application like a profiler like VisualVM (invoked with jvisualvm comamnd) or the jhat utility to take heap dumps.
Thanks once again for letting me know the existence of another Heap Analysis tool jhat.
0

Depends on the JVM and native libs. You may see JVM threads show up with distinct PIDs in ps. Generally speaking the child PIDs will have parent PIDs with java processes as those that are threads.

You cannot say for sure that the # of Linux java processes == # of instantiated JVMs.

2 Comments

On Linux, the JVM uses true native threads, which are similar to processes. However, they are not the same thing, as only a process has its own address space.
I'm addressing your last paragraph. I think you can say that (process count does equal JVM count) for sure, regardless of ps output.

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.