JINFO命令输出给定的java进程的所有配置信息
JPS命令是列出当前所有的java进程
[root@harlan-web ~]# jps 11204 Bootstrap 76116 Jps
查看Bootstrap中的所有配置信息
[root@harlan-web ~]# jinfo 11204 Attaching to process ID 11204, please wait... Error attaching to process: java.lang.RuntimeException: can't determine target's VM version : field "_reserve_for_allocation_prefetch" not found in type Abstract_VM_Version sun.jvm.hotspot.debugger.DebuggerException: java.lang.RuntimeException: can't determine target's VM version : field "_reserve_for_allocation_prefetch" not found in type Abstract_VM_Version at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:435) at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:305) at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140) at sun.jvm.hotspot.tools.Tool.start(Tool.java:185) at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118) at sun.jvm.hotspot.tools.JInfo.main(JInfo.java:138) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.tools.jinfo.JInfo.runTool(JInfo.java:108) at sun.tools.jinfo.JInfo.main(JInfo.java:76) Caused by: java.lang.RuntimeException: can't determine target's VM version : field "_reserve_for_allocation_prefetch" not found in type Abstract_VM_Version at sun.jvm.hotspot.runtime.VM.<init>(VM.java:291) at sun.jvm.hotspot.runtime.VM.initialize(VM.java:370) at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:431) ... 11 more
上述红色的字体提示找不到VM的版本信息。
查看环境中的JDK版本信息
查看当前环境的JDK版本,版本为12.0.1
[root@harlan-web ~]# java -version java version "12.0.1" 2019-04-16 Java(TM) SE Runtime Environment (build 12.0.1+12) Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
查看jinfo所使用的JDK版本,版本为1.8.0
由至推断,jinfo的JDK的版本与java进程使用JDK版本不一致。
解决方法:
知道了问题所在,使两个版本的JDK进行统一。
重新将当前环境的JAVA的JDK统一为1.8.0版本
ln -sf /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/bin/java /etc/alternatives/java
[root@harlan-web ~]# java -version openjdk version "1.8.0_262" OpenJDK Runtime Environment (build 1.8.0_262-b10) OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
然后,再次使用jinfo命令
[root@harlan-web ~]# jinfo 76529 Attaching to process ID 76529, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.262-b10 Java System Properties: java.runtime.name = OpenJDK Runtime Environment java.vm.version = 25.262-b10 sun.boot.library.path = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/lib/amd64 java.protocol.handler.pkgs = org.apache.catalina.webresources shared.loader = java.vendor.url = http://java.oracle.com/
至此,显示正常,问题解决。