There are times that we want to figure out what command line options where used to start a java process. There are a few ways we can do this. The examples below assume PID is set to the process id we want to inspect:

ps

1
2
3
4
ps -f $PID

UID          PID    PPID  C STIME TTY      STAT   TIME CMD
adrian    316721  313854  0 16:15 pts/6    Sl+    0:00 /home/adrian/.cache/bazel/_bazel_adrian/28381a26654a75034a8803698f5ef496/execroot/__main__/bazel-out/k8-fastbuild/bin/main.runfiles/local_jdk/bin/java -classpath main.jar -Xdebug example.Main

Using jps

jps doesn’t allow us to list a single process id, but we can see the command line arguments for all java processes:

1
jps -lvm

Using jcmd

jcmd is the recommended way to inspect java processes. If we want to get information about the command line that was used to start a process we can use:

1
2
3
4
5
6
7
8
jcmd $PID VM.command_line

316721:
VM Arguments:
jvm_args: -Xdebug
java_command: example.Main
java_class_path (initial): main.jar
Launcher Type: SUN_STANDARD

There are some jvm options that are set by default without the need for a command line argument. We can use jcmd to inspect those too:

1
2
jcmd $PID VM.flags
jcmd $PID VM.system_properties
[ debugging  java  linux  ]
Passing Arguments To a Java Binary Ran With Bazel
Getting PID for Java Process
Installing Ubuntu on an old computer - Broken graphics
Using lsof to find who is using a file or socket
Advanced top for system diagnosis