List of Java processes

前端 未结 18 2207
长发绾君心
长发绾君心 2020-12-22 16:44

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.

相关标签:
18条回答
  • 2020-12-22 17:10

    To know the list of java running on the linux machine. ps -e | grep java

    0 讨论(0)
  • 2020-12-22 17:14

    When I want to know if a certain Java class is getting executed, I use the following command line:

    ps ww -f -C java | grep "fully.qualified.name.of.class"
    

    From the OS side view, the process's command name is "java". The "ww" option widens the colum's maximum characters, so it's possible to grep the FQN of the related class.

    0 讨论(0)
  • 2020-12-22 17:17

    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

    0 讨论(0)
  • 2020-12-22 17:17

    ps aux | grep java

    or

    $ ps -fea|grep -i java

    0 讨论(0)
  • 2020-12-22 17:18

    If I want simply list java processes, use:

    ps -A | grep java
    
    0 讨论(0)
  • 2020-12-22 17:21

    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
    
    0 讨论(0)
提交回复
热议问题