JVM and Java Linux process

21,168

Solution 1

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

Solution 2

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.

Share:
21,168
Gnanam
Author by

Gnanam

Updated on July 09, 2022

Comments

  • Gnanam
    Gnanam almost 2 years

    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.

  • Gnanam
    Gnanam over 13 years
    Can we say # of java processes equals # of JVMs running at all cases?
  • Matthew Flaschen
    Matthew Flaschen over 13 years
    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.
  • Matthew Flaschen
    Matthew Flaschen over 13 years
    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.
  • Matthew Flaschen
    Matthew Flaschen over 13 years
    I'm addressing your last paragraph. I think you can say that (process count does equal JVM count) for sure, regardless of ps output.
  • CruiZen
    CruiZen over 12 years
    @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.
  • Gnanam
    Gnanam over 12 years
    Thanks once again for letting me know the existence of another Heap Analysis tool jhat.