2

On Ubuntu, man jps says

jps - Lists the instrumented Java Virtual Machines (JVMs) on the target system.

What does a "instrumented Java Virtual Machine" mean?

$ jps -v
29584 Jps -Dapplication.home=/usr/lib/jvm/java-11-openjdk-amd64 -Xms8m -Djdk.module.main=jdk.jcmd

Is a jps process a JVM process, by definition?

jps is an ELF file, not a JVM bytecode program compiled from a Java program:

$ file /usr/lib/jvm/java-11-openjdk-amd64/bin/jps
/usr/lib/jvm/java-11-openjdk-amd64/bin/jps: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=3f48c70ab711b493ee793c92c19b3a884896bb4d, stripped

$ jps -v
16462 Jps -Dapplication.home=/usr/lib/jvm/java-11-openjdk-amd64 -Xms8m -Djdk.module.main=jdk.jcmd
halfer
  • 19,824
  • 17
  • 99
  • 186
Tim
  • 1
  • 141
  • 372
  • 590
  • It is an instrumented JVM. A JVM is a proces. Unclear what you're asking. – user207421 Apr 14 '19 at 01:45
  • What does a "instrumented Java Virtual Machine" mean? Why is a jps process a JVM process? – Tim Apr 14 '19 at 01:54
  • An instrumented JVM is one that is currently exporting JMX instrumentation endpoints. A `jps` process is an instrumented JVM because that's what it says in your quotation. – user207421 Apr 14 '19 at 11:16
  • Thanks. (1) What does "exporting JMX instrumentation endpoints" mean? (2) Can you start a non-instrumented JVM? – Tim Apr 14 '19 at 11:23

2 Answers2

8

What does a "instrumented Java Virtual Machine" mean?

An instrumented JVM is a JVM that is instrumented.

However, that is a fatuous definition, and I have not been able to find a clearly documented definition of what "instrumented" really means.

In fact, it potentially applies to (at least) any HotSpot JVM since Java 5.0. The current implementation of jps looks for instrumented JVMs as follows:

  • If you specify a hostid, jps attempts to contact an RMI service (jstatd) on the host to find out about the Java processes.

  • If you don't specify a hostid, jps finds Java processes by looking for /tmp/hsperfdata_<username> directories that are readable by the current user; see How do jps, jinfo, jstat, jmap and jstack get information about local Java processes?. A JVM will create one of these directories unless you launch the JVM with -XX:-UsePerfData or -XX:-PerfDisableSharedMem. (Thanks to @apangin for this information.)

But ultimately we still have a circular (working) definition: an "instrumented JVM" is one that jps is able to find.


Is a jps process a JVM process, by definition?

The current implementation of jps is a Java class that runs in a JVM created by a generic launcher (the jps executable). However, there is no "definition" that says that is has to be implemented this way.

Note that since jps without any arguments will find itself (at least on my system) that strongly (IMO) suggests that the current implementation uses an instrumented JVM.


jps is an ELF file, not a JVM bytecode program compiled from a Java program

That actually has nothing to do with it. A JVM is a thing (a virtual machine) that is executing a Java program. It is not relevant to "JVM-ness" how the program is launched, or even whether the program was represented as bytecodes at launch time.

With jlink (or older 3rd-party products) an ordinary Java (bytecode) program can be turned into a native executable. On Linux, jlink will produce an ELF file. Yet, when you run the ELF file, you will still have a JVM.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
2

Most of the commands which come with the JVM are actually implemented using Java. In this case, jps starts a JVM to run a class sun.tools.jps.Jps

http://www.docjar.com/html/api/sun/tools/jps/Jps.java.html

Similarly javac actually runs com.sun.tools.javac.Main

https://docs.oracle.com/javase/9/docs/api/com/sun/tools/javac/Main.html

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