JVM - jps工具

2021/09/29 JVM 共 7447 字,约 22 分钟
Bob.Zhu

jps(JVM Process Status) 命令类似 UNIX 的 ps 命令,用于查看所有 Java 进程的启动类、 传入参数和 Java 虚拟机参数等信息。

jps -help

jps -help
usage: jps [-help]
       jps [-q] [-mlvV] [<hostid>]

Definitions:
    <hostid>:      <hostname>[:<port>]

jps

显示虚拟机执行主类名称以及这些进程的本地虚拟机唯一 ID(Local Virtual Machine Identifier,LVMID)。

jps
64932 Jps
63211 Launcher
623
1167

jps -q

只输出进程的本地虚拟机唯一 ID。

jps -q
63211
65949
623
1167

jps -l

输出主类的全名,如果进程执行的是 Jar 包,输出 Jar 路径。

jps -l
19343 org.apache.catalina.startup.Bootstrap
29222 sun.tools.jps.Jps
32577 org.apache.catalina.startup.Bootstrap
14029 org.apache.catalina.startup.Bootstrap

jps -m

输出传递给 Java 进程 main() 函数的参数。

jps -m
19343 Bootstrap start
29414 Jps -m
32577 Bootstrap start
14029 Bootstrap start

本地macOS上的Java应用含有更多参数:

jps -lm
63211 org.jetbrains.jps.cmdline.Launcher /Applications/IntelliJ IDEA.app/Contents/lib/protobuf-java-3.15.8.jar:/Applications/IntelliJ IDEA.app/Contents/lib/3rd-party.jar:/Applications/IntelliJ IDEA.app/Contents/lib/slf4j.jar:/Applications/IntelliJ IDEA.app/Contents/lib/jna.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/maven-resolver-connector-basic-1.3.3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/jps-javac-extension-1.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/jps-builders.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/jps-builders-6.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/javac2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/maven-resolver-transport-file-1.3.3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/aether-dependency-resolver.jar:/Applications/IntelliJ IDEA.app/Contents/lib/jna-platform.jar:/Applications/IntelliJ IDEA.app/Contents/lib/kotlin-stdlib-jdk8.jar:/Applications/IntelliJ IDEA.app
80734 sun.tools.jps.Jps -lm
623
1167

jps -v

输出虚拟机进程启动时 JVM 参数。

jps -v
19343 Bootstrap -Djava.util.logging.config.file=/home/jyapp/app/apache-tomcat-rms/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -javaagent:/home/jyapp/devops/arms/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar -Darms.licenseKey=gp5yh3tvif@9b2a976d3d73e12 -Darms.appName=apache-tomcat-rms -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Djava.endorsed.dirs=/home/jyapp/app/apache-tomcat-rms/endorsed -Dcatalina.base=/home/jyapp/app/apache-tomcat-rms -Dcatalina.home=/home/jyapp/app/apache-tomcat-rms -Djava.io.tmpdir=/home/jyapp/app/apache-tomcat-rms/temp
29763 Jps -Denv.class.path=.::/home/jyapp/app/jdk1.7.0_76/lib:/home/jyapp/app/jdk1.7.0_76/jre/lib -Dapplication.home=/home/jyapp/app/jdk1.7.0_76 -Xms8m
32577 Bootstrap -Djava.util.logging.config.file=/home/jyapp/app/tomcat-8096/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -Dcatalina.base=/home/jyapp/app/tomcat-8096 -Dcatalina.home=/home/jyapp/app/tomcat-8096 -Djava.io.tmpdir=/home/jyapp/app/tomcat-8096/temp
14029 Bootstrap -Djava.util.logging.config.file=/home/jyapp/app/tomcat-8095/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dcatalina.base=/home/jyapp/app/tomcat-8095 -Dcatalina.home=/home/jyapp/app/tomcat-8095 -Djava.io.tmpdir=/home/jyapp/app/tomcat-8095/temp

本地macOS上的Java应用含有更多参数:

jps -lmv
80821 sun.tools.jps.Jps -lmv -Denv.class.path=/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/lib:/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/lib/dt.jar:. -Dapplication.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home -Xms8m
63211 org.jetbrains.jps.cmdline.Launcher /Applications/IntelliJ IDEA.app/Contents/lib/protobuf-java-3.15.8.jar:/Applications/IntelliJ IDEA.app/Contents/lib/3rd-party.jar:/Applications/IntelliJ IDEA.app/Contents/lib/slf4j.jar:/Applications/IntelliJ IDEA.app/Contents/lib/jna.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/maven-resolver-connector-basic-1.3.3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/jps-javac-extension-1.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/jps-builders.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/jps-builders-6.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/javac2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/maven-resolver-transport-file-1.3.3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/java/lib/aether-dependency-resolver.jar:/Applications/IntelliJ IDEA.app/Contents/lib/jna-platform.jar:/Applications/IntelliJ IDEA.app/Contents/lib/kotlin-stdlib-jdk8.jar:/Applications/IntelliJ IDEA.app -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs="" -Dpreload.project.path=/Users/adolphor/IdeaProjects/bob/adolphor -Dpreload.config.path=/Users/adolphor/Library/Application Support/JetBrains/IntelliJIdea2021.2/options -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djdt.compiler.useSingleThread=true -Daether.connector.resumeDownloads=false -Dio.netty.initialSeedUniquifier=-806027382327145913 -Dfile.encoding=UTF-8 -Duser.language=zh -Duser.country=CN -Didea.paths.selector=IntelliJIdea2021.2 -Didea.home.path=/Applications/IntelliJ IDEA.app/Contents -Didea.config.path=/Users/adolphor/Library/Application Support/JetBrains/IntelliJIdea2021.2 -Didea.plugins.path=/Users/adolphor/Library/Application Support/JetBrains/IntelliJIdea2021.2/plugins -Djps.log.dir=/Users/adolphor/Library/Logs/JetBrains/IntelliJIdea2021.2/build-log -Djps.fallback.jdk.home=/Applications/IntelliJ IDEA.app/Contents/jbr/Contents/Home -Djps.fallback.jdk.version=11.0.11 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=/Users/adolpho
623  -Xmx2048m -Xms128m -XX:ReservedCodeCacheSize=512m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -ea -Dsun.io.useCanonCaches=false -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off -XX:ErrorFile=/Users/adolphor/java_error_in_idea_%p.log -XX:HeapDumpPath=/Users/adolphor/java_error_in_idea.hprof -Djb.vmOptionsFile=/Users/adolphor/Library/Application Support/JetBrains/IntelliJIdea2021.2/idea.vmoptions -Dsplash=true -Didea.home.path=/Applications/IntelliJ IDEA.app/Contents -Didea.jre.check=true -Didea.executable=idea -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.paths.selector=IntelliJIdea2021.2 -Didea.vendor.name=JetBrains
1167  -XX:ReservedCodeCacheSize=512m -Xms128m -Xmx2048m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -ea -Dsun.io.useCanonCaches=false -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off -XX:ErrorFile=/Users/adolphor/java_error_in_datagrip_%p.log -XX:HeapDumpPath=/Users/adolphor/java_error_in_datagrip.hprof -Djb.vmOptionsFile=/Users/adolphor/Library/Application Support/JetBrains/DataGrip2021.2/datagrip.vmoptions -Didea.home.path=/Applications/DataGrip.app/Contents -Didea.executable=datagrip -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.platform.prefix=DataGrip -Didea.paths.selector=DataGrip2021.2 -Didea.vendor.name=JetBrains

参考资料

文档信息

Search

    Table of Contents