-5

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

Thanks.

  • Did you google "instrumented jvm" at all? This question doesn't show any evidence you've even tried to do any research – Stephen Harris Apr 14 at 1:34
  • 1
    What shall I say? The only one I found doesn't even define what is an instrumented JVM agassiz.cs.umn.edu/SanFrancisco/jvm_intro.html – Tim Apr 14 at 1:56
  • @StephenHarris - I concur with Tim. I have been trying to figure this out for the past hour via Google, looking at the source code, etc. The answer is NOT readily available via Google. – Stephen C Apr 14 at 2:05
  • 1
    Maybe I had more exposure to AppDev teams, so I have the necessary background. But, anyway, this is a Java question and better on StackOverflow. It's not a Unix question. – Stephen Harris Apr 14 at 2:12
  • 1
    @mosvy That definitely belongs on StackOverflow! But in general terms an instrumented application is one that has "probes" in it to report on health/performance type stats, to allow execution tracing, etc etc Think of an "instrumentation dashboard". Two common commercial tools used by AppDev teams may be AppDynamics or Dynatrace. Even the kernel can be instrumented (eg with SystemTap). An instrumented JVM is, therefore, one where you can get stats from the JVM itself. – Stephen Harris Apr 14 at 10:55
3

What does a "instrumented Java Virtual Machine" mean?

On Linux, an "instrumented Java Virtual Machine" is the vm started with the -XX:+UsePerfData option -- which is on by default.

That will cause it the store performance & other info into a /tmp/hsperfdata_$USER/$PID file, which will be read by the jps(1) tool.

If you want to start an un-instrumented JVM, run it as java -XX:-UsePerfData YourClass. That will prevent it from writing that hsperfdata and from appearing in jps's output.

Is a jps process a JVM process, by definition?

Yes

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

jps is just a launcher, which will start a JVM and load the sun.tools.jps.Jps java class from tools.jar into it. The JVM started this way will write its own hsperfdata file, and that's why the Jps class appears in its own output. You can turn that off by passing the same option as above to the JVM via the -J switch:

$ jps
12583 Jps
$ jps -J-XX:-UsePerfData
$
  • Thanks. jstack, jinfo, jmap use dynamic active mechanism instead of files, to communicate with existing JVM processes. Do they require the JVM process to be instrumented? Are they themselves JVM processes and if yes, instrumented JVM processes? – Tim Apr 14 at 23:18
  • Why don't you try it? start a java program with java -XX:-UsePerfData ClassName, get its pid with pgrep, and you'll see that jstack, jinfo, jmap will work with it. All those programs are launchers just like jps, and they all accept the -J option to pass arguments to the JVMs they start. – mosvy Apr 14 at 23:43
  • For the record, the "dynamic active mechanism" seem to be ptrace(2) for jinfo and jmap and a /tmp/.java_pid$PID unix domain socket that a JVM will create upon having an .attach_pid$PID file created in its cwd and receiving a SIGQUIT signal -- for jstack. – mosvy Apr 15 at 0:06
1

Yes, jps is a Java application.

From an Oracle blog:

That's where the

jps

command comes in handy. It will list the process ids for all virtual machines started for the JDK installation directory you are using. Your output, specifically the process ids, will probably be different:

> jps
5156 Jps
4276 MyFrame

Since the

jps

command is itself a Java program, it shows up in the list, too.

  • Thanks. "jps command is itself a Java program". But jps is an ELF file just like the java executable file, not a JVM bytecode program compiled from a Java program. See my update – Tim Apr 14 at 10:56
  • 1
    @Tim Java programs may be compiled into binary executables. See e.g. How can I convert my Java program to an .exe file? – Kusalananda Apr 14 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.