jps and jcmd did not show me any results when I tried this using openjdk-1.8 on redhat linux. But even if this were done, it only shows processes under the current user that do not work in my case. Using ps | grep is what I ended up with, but the class path for some Java applications can be extremely long, which makes the results illegible, so I used sed to remove it. This is a little rude, but removes everything except: PID, User, java-class / jar, args.
ps -o pid,user,cmd -C java | sed -e 's/\([0-9]\+ *[^ ]*\) *[^ ]* *\([^$]*\)/\1 \2/' -e 's/-c[^ ]* [^ ]* \|-[^ ]* //g'
The results look something like this:
PID USER CMD 11251 userb org.apache.zookeeper.server.quorum.QuorumPeerMain ../config/zookeeper.properties 19574 userb com.intellij.idea.Main 28807 root org.apache.nifi.bootstrap.RunNiFi run 28829 root org.apache.nifi.NiFi
An alternative for windows to display all processes is:
WMIC path win32_process where "Caption='java.exe'" get ProcessId,Commandline
But this will require analysis to make it more understandable.
Mike Feb 16 '17 at 18:43 2017-02-16 18:43
source share