JVM之jps命令
Posted dalianpai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JVM之jps命令相关的知识,希望对你有一定的参考价值。
jps(JVM Process Status Tool)
作用:列出正在运行的虚拟机进程。并显示虚拟机执行主类(Main Class,main()函数所在的类)名称以及这些进程的本地虚拟机唯一ID(Local Virtual Machine Identifier,LVMID)
虽然功能比较单一,但它是使用频率最高的JDK命令行工具,因为其他的JDK工具大多需要输入它查询到的唯一ID来确定要监控的是哪一个虚拟机进程。对于本地虚拟机进程来说,唯一ID与操作系统的进程ID是一致的。使用Windows的任务管理器或者UNIX的ps命令也可以查询到虚拟机进程的唯一ID,但如果同时启动多个虚拟机进程,无法根据进程名称定位时,那只有依赖jps命令 显示主类的功能 才能区分了。
命令格式:
jps[options][hostid]
参数解释:
第一个参数:options
-q:显示进程ID
-m:显示进程ID,主类名称,以及传入main方法的参数
-l:显示进程ID,主类全名
-v:显示进程ID,主类名称,以及传入JVM的参数
-V:显示进程ID,主类名称
[-mlvV]可以任意组合使用
第二个参数:hostid
主机或者是服务器的ip,如果不指定,就默认为当前的主机或者是服务器。
注意:如果需要查看其他机器上的jvm进程,需要在待查看机器上启动jstatd。
测试类:
/** * @author WGR * @create 2020/4/6 -- 22:58 */ public class JpsTest { public static void main(String[] args) throws IOException { System.out.println("jps"); System.in.read(); } }
D:Toolsjdk1.8.0_131in>jps -V 17712 18276 Launcher 16536 Jps 16284 JpsTest 2892 RemoteMavenServer D:Toolsjdk1.8.0_131in>jps -q 17712 18276 16284 28012 2892 D:Toolsjdk1.8.0_131in>jps -m 17712 22208 Jps -m 18276 Launcher C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/lib/asm-all-7.0.1.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/plugins/java/lib/maven-model-builder-3.3.9.jar;C :/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/lib/netty-buffer-4.1.41.Final.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/lib/commons-logging-1.2.jar;C:/Program Files/JetBrai ns/IntelliJ IDEA 2019.3.2/plugins/java/lib/jps-builders-6.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/lib/lz4-java-1.6.0.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/ lib/trove4j.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/lib/resources_en.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/lib/qdox-2.0-M10.jar;C:/Program Files/JetBrains/ IntelliJ IDEA 2019.3.2/lib/jna-platform.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/lib/netty-codec-4.1.41.Final.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/lib/nano xml-2.2.3.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/lib/gson-2.8.5. 16284 JpsTest 2892 RemoteMavenServer D:Toolsjdk1.8.0_131in>jps -l 17712 18276 org.jetbrains.jps.cmdline.Launcher 16284 com.example.test.JpsTest 2892 org.jetbrains.idea.maven.server.RemoteMavenServer 7804 sun.tools.jps.Jps D:Toolsjdk1.8.0_131in>jps -v 17712 exit -Xms380m -Xmx2033m -XX:ReservedCodeCacheSize=240m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -X X:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Dfile.encoding=UTF-8 -javaagent:D:Toolsjetbrains-agentjetbrains-agent.jar -Dide.run.dashboard=true -Djb.vmOptionsFile=C: Usersasus.IntelliJIdea2019.3configidea64.exe.vmoptions -Djava.library.path=C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2jbrin;C:Program FilesJetBrainsIntelliJ IDEA 2019. 3.2jbrinserver -Didea.jre.check=true -Dide.native.launcher=true -Didea.paths.selector=IntelliJIdea2019.3 -XX:ErrorFile=C:Usersasusjava_error_in_idea_%p.log -XX:HeapDumpPath=C:U sersasusjava_error_in_idea.hprof 13748 Jps -Denv.class.path=.;D:Toolsjdk1.8.0_131libdt.jar;D:Toolsjdk1.8.0_131lib ools.jar; -Dapplication.home=D:Toolsjdk1.8.0_131 -Xms8m 18276 Launcher -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs="" -Djdt.compiler.useSingleThread=true -Dpreload.project.path=E:/IdeaSpace/demo -Dpreload.config.path=C:/Users/asus /.IntelliJIdea2019.3/config/options -Dexternal.project.config=C:Usersasus.IntelliJIdea2019.3systemexternal_build_systemdemo.bf8e5b97 -Dcompile.parallel=false -Drebuild.on.dependen cy.change=true -Djava.net.preferIPv4Stack=true -Dio.netty.initialSeedUniquifier=5101738367496239099 -Dfile.encoding=UTF-8 -Duser.language=zh -Duser.country=CN -Didea.paths.selector=Inte lliJIdea2019.3 -Didea.home.path=C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2 -Didea.config.path=C:Usersasus/.IntelliJIdea2019.3/config -Didea.plugins.path=C:Usersasus/.IntelliJ Idea2019.3/config/plugins -Djps.log.dir=C:/Users/asus/.IntelliJIdea2019.3/system/log/build-log -Djps.fallback.jdk.home=C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/jbr -Djps.fallba ck.jdk.version=11.0.5 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/asus/.IntelliJIdea2019.3/system/compile-s 16284 JpsTest -javaagent:C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2libidea_rt.jar=64492:C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2in -Dfile.encoding=UTF-8 2892 RemoteMavenServer -Djava.awt.headless=true -Dmaven.defaultProjectBuilder.disableGlobalModelCache=true -Xmx768m -Didea.maven.embedder.version=3.5.4 -Dmaven.ext.class.path=C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2pluginsmavenlibmaven-event-listener.jar -Dfile.encoding=UTF-8 D:Toolsjdk1.8.0_131in>jps -v 17712 exit -Xms380m -Xmx2033m -XX:ReservedCodeCacheSize=240m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -X X:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Dfile.encoding=UTF-8 -javaagent:D:Toolsjetbrains-agentjetbrains-agent.jar -Dide.run.dashboard=true -Djb.vmOptionsFile=C: Usersasus.IntelliJIdea2019.3configidea64.exe.vmoptions -Djava.library.path=C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2jbrin;C:Program FilesJetBrainsIntelliJ IDEA 2019. 3.2jbrinserver -Didea.jre.check=true -Dide.native.launcher=true -Didea.paths.selector=IntelliJIdea2019.3 -XX:ErrorFile=C:Usersasusjava_error_in_idea_%p.log -XX:HeapDumpPath=C:U sersasusjava_error_in_idea.hprof 2000 Jps -Denv.class.path=.;D:Toolsjdk1.8.0_131libdt.jar;D:Toolsjdk1.8.0_131lib ools.jar; -Dapplication.home=D:Toolsjdk1.8.0_131 -Xms8m 24004 JpsTest -Xmn8m -javaagent:C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2libidea_rt.jar=57913:C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2in -Dfile.encoding=UTF-8 2892 RemoteMavenServer -Djava.awt.headless=true -Dmaven.defaultProjectBuilder.disableGlobalModelCache=true -Xmx768m -Didea.maven.embedder.version=3.5.4 -Dmaven.ext.class.path=C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2pluginsmavenlibmaven-event-listener.jar -Dfile.encoding=UTF-8 6940 Launcher -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs="" -Djdt.compiler.useSingleThread=true -Dpreload.project.path=E:/IdeaSpace/demo -Dpreload.config.path=C:/Users/asus/ .IntelliJIdea2019.3/config/options -Dexternal.project.config=C:Usersasus.IntelliJIdea2019.3systemexternal_build_systemdemo.bf8e5b97 -Dcompile.parallel=false -Drebuild.on.dependenc y.change=true -Djava.net.preferIPv4Stack=true -Dio.netty.initialSeedUniquifier=5101738367496239099 -Dfile.encoding=UTF-8 -Duser.language=zh -Duser.country=CN -Didea.paths.selector=Intel liJIdea2019.3 -Didea.home.path=C:Program FilesJetBrainsIntelliJ IDEA 2019.3.2 -Didea.config.path=C:Usersasus/.IntelliJIdea2019.3/config -Didea.plugins.path=C:Usersasus/.IntelliJI dea2019.3/config/plugins -Djps.log.dir=C:/Users/asus/.IntelliJIdea2019.3/system/log/build-log -Djps.fallback.jdk.home=C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.2/jbr -Djps.fallbac k.jdk.version=11.0.5 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/asus/.IntelliJIdea2019.3/system/compile-s D:Toolsjdk1.8.0_131in>jps 17712 24004 JpsTest 15580 Jps 2892 RemoteMavenServer 6940 Launcher D:Toolsjdk1.8.0_131in>
以上是关于JVM之jps命令的主要内容,如果未能解决你的问题,请参考以下文章