Is there a way to find the name of the main class running the JVM using the PID?
This is what has already been done in jvisualvm, for example.
You can use the command jps:
jps
jps -l | grep pid
-lprints the full class name. See this link for official documentation.
-l
you can use below command
jps -m or jps -l
jps - Java running processes
Java running processes
he will list all the "processes" and PIDrunning in the OS
PID