jdk8下:jps命令

列出正在运行的虚拟机进程,并显示虚拟机执行主类(main class, main()函数所在的类)名称,以及这些进程的本地虚拟机Id(LVMID)。

使用方法:在当前命令行下打jps(jps存放在JAVA_HOME/bin/jps,使用时为了方便请将JAVA_HOME/bin/加入到Path) 。

➜  ~ jps
7808 Launcher
2803 Main
5635 RemoteJdbcServer
5254 RemoteJdbcServer
13640 Jps
3400 RemoteMavenServer
5480 Main
7694 CosumerAckTest
22606 RemoteJdbcServer
4287 RemoteJdbcServer

参数

-q 只显示pid,不显示class名称,jar文件名和传递给main方法的参数

➜  ~ jps -q
7808
2803
5635
5254
15240
3400
5480
7694
22606
4287

-m 输出传递给main方法的参数,在嵌入式jvm上可能是null

[@5fb59500efa6 ~]$ jps -m
42229 App /opt/src/app/config/zk.json
12317 Jps -m

-l 输出应用程序main class的完整package名或者应用程序的jar文件完整路径名

[@5fb59500efa6 ~]$ jps -l
12371 sun.tools.jps.Jps
42229 com.sohu.sns.reco.App

-v 输出传递给JVM的参数

[@5fb59500efa6 ~]$ jps -v
42229 App -Xms6114m -Xmx6114m -Xmn2200m -Xss256k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/logs/ -Djava.awt.headless=true -XX:MaxPermSize=512m -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dfile.encoding=UTF-8 -Dmonitor_agent_app_id=184461539_7eb18530-4ea0-11e8-ab05-00163e0f092d -Denv=PRODUCT -Dlogback.configurationFile=/opt/src/config/logback.xml
12414 Jps -Denv.class.path=./:/opt/apps/jdk/lib:/opt/apps/jdk/lib/tools.jar -Dapplication.home=/opt/apps_install/jdk1.7.0 -Xms8m

sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to the process

➜ ~ jinfo 31983
Attaching to process ID 31983, please wait…
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to the process
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to the process
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal LinuxDebuggerLocalWorkerThread.execute(LinuxDebuggerLocal.java:163)atsun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach(LinuxDebuggerLocal.java:278)atsun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:671)atsun.jvm.hotspot.HotSpotAgent.setupDebuggerLinux(HotSpotAgent.java:611)atsun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:337)atsun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:304)atsun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140)atsun.jvm.hotspot.tools.Tool.start(Tool.java:185)atsun.jvm.hotspot.tools.Tool.execute(Tool.java:118)atsun.jvm.hotspot.tools.JInfo.main(JInfo.java:138)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:498)atsun.tools.jinfo.JInfo.runTool(JInfo.java:108)atsun.tools.jinfo.JInfo.main(JInfo.java:76)Causedby:sun.jvm.hotspot.debugger.DebuggerException:Cantattachtotheprocessatsun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach0(NativeMethod)atsun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.access L i n u x D e b u g g e r L o c a l W o r k e r T h r e a d . e x e c u t e ( L i n u x D e b u g g e r L o c a l . j a v a : 163 ) a t s u n . j v m . h o t s p o t . d e b u g g e r . l i n u x . L i n u x D e b u g g e r L o c a l . a t t a c h ( L i n u x D e b u g g e r L o c a l . j a v a : 278 ) a t s u n . j v m . h o t s p o t . H o t S p o t A g e n t . a t t a c h D e b u g g e r ( H o t S p o t A g e n t . j a v a : 671 ) a t s u n . j v m . h o t s p o t . H o t S p o t A g e n t . s e t u p D e b u g g e r L i n u x ( H o t S p o t A g e n t . j a v a : 611 ) a t s u n . j v m . h o t s p o t . H o t S p o t A g e n t . s e t u p D e b u g g e r ( H o t S p o t A g e n t . j a v a : 337 ) a t s u n . j v m . h o t s p o t . H o t S p o t A g e n t . g o ( H o t S p o t A g e n t . j a v a : 304 ) a t s u n . j v m . h o t s p o t . H o t S p o t A g e n t . a t t a c h ( H o t S p o t A g e n t . j a v a : 140 ) a t s u n . j v m . h o t s p o t . t o o l s . T o o l . s t a r t ( T o o l . j a v a : 185 ) a t s u n . j v m . h o t s p o t . t o o l s . T o o l . e x e c u t e ( T o o l . j a v a : 118 ) a t s u n . j v m . h o t s p o t . t o o l s . J I n f o . m a i n ( J I n f o . j a v a : 138 ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( N a t i v e M e t h o d A c c e s s o r I m p l . j a v a : 62 ) a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( D e l e g a t i n g M e t h o d A c c e s s o r I m p l . j a v a : 43 ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( M e t h o d . j a v a : 498 ) a t s u n . t o o l s . j i n f o . J I n f o . r u n T o o l ( J I n f o . j a v a : 108 ) a t s u n . t o o l s . j i n f o . J I n f o . m a i n ( J I n f o . j a v a : 76 ) C a u s e d b y : s u n . j v m . h o t s p o t . d e b u g g e r . D e b u g g e r E x c e p t i o n : C a n ′ t a t t a c h t o t h e p r o c e s s a t s u n . j v m . h o t s p o t . d e b u g g e r . l i n u x . L i n u x D e b u g g e r L o c a l . a t t a c h 0 ( N a t i v e M e t h o d ) a t s u n . j v m . h o t s p o t . d e b u g g e r . l i n u x . L i n u x D e b u g g e r L o c a l . a c c e s s 100(LinuxDebuggerLocal.java:62)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal 1AttachTask.doit(LinuxDebuggerLocal.java:269)atsun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal 1 A t t a c h T a s k . d o i t ( L i n u x D e b u g g e r L o c a l . j a v a : 269 ) a t s u n . j v m . h o t s p o t . d e b u g g e r . l i n u x . L i n u x D e b u g g e r L o c a l LinuxDebuggerLocalWorkerThread.run(LinuxDebuggerLocal.java:138)

解决办法:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

你可能感兴趣的:(core,java,jvm)