List of Java processes
Solution 1
try:
ps aux | grep java
and see how you get on
Solution 2
Recent Java comes with Java Virtual Machine Process Status Tool "jps"
http://download.oracle.com/javase/1.5.0/docs/tooldocs/share/jps.html
For example,
[nsushkin@fulton support]$ jps -m
2120 Main --userdir /home/nsushkin/.netbeans/7.0 --branding nb
26546 charles.jar
17600 Jps -m
Solution 3
jps -lV
is most useful. Prints just pid and qualified main class name:
2472 com.intellij.idea.Main
11111 sun.tools.jps.Jps
9030 play.server.Server
2752 org.jetbrains.idea.maven.server.RemoteMavenServer
Solution 4
Starting from Java 7, the simplest way and less error prone is to simply use the command jcmd
that is part of the JDK such that it will work the same way on all OS.
Example:
> jcmd
5485 sun.tools.jcmd.JCmd
2125 MyProgram
jcmd
allows to send diagnostic command requests to a running Java Virtual Machine (JVM).
More details about how to use jcmd
.
See also the jcmd
Utility
Solution 5
You can use single command pgrep as well (doesn't require you to use pipes and multiple commands):
pgrep -fl java
Jacek Koralik
Updated on February 28, 2021Comments
-
Jacek Koralik about 3 years
How can I list all Java processes in bash? I need an command line. I know there is command
ps
but I don't know what parameters I need to use. -
jake almost 9 yearsJust a note: jps only ships with the JDK, not the JRE. Machines with plain ol' Java runtimes on them won't have this tool.
-
Sridhar Sarnobat over 7 yearsWow, that's even better than
jps
-
vaquar khan almost 7 yearsit should be ps -eaf | grep Java not [j]ava
-
Ilya Gazman almost 7 years@vaquarkhan dude just try to run both yours and mine suggestions and see whats the difference, they both will work
-
vaquar khan almost 7 yearsBoth give same results however [j]ava is confusing
-
Toby Speight almost 7 yearsThank you for this code snippet, which may provide some immediate help. A proper explanation would greatly improve its educational value by showing why this is a good solution to the problem, and would make it more useful to future readers with similar, but not identical, questions. Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply. In particular, why doesn't the second of those show the
grep
process? -
Jet over 6 yearshow can I get just count of running java process ?
-
David Clarke almost 5 yearsThis is what I was looking for -
$ top
just gives "java" as the command which isn't all that helpful when trying to figure out which process is hogging the cpu.$ ps ww -fC java
provides the missing pieces of the puzzle. -
Charles Naccio over 4 yearsNice an clean output; exactly what I was looking for. Thanks!
-
Davut Gürbüz over 3 yearsI've been utilizing this for years, however it only shows current user's processes. Not all processes on the machine. Admin user and normal user processes might be different.
-
Aleksandar over 2 yearsThat works great in a container with limited packages. For example if
ps
is missing.