3

my jdk version is 1.8.0_111 and I'm reading a book on JVM. When I tried the command jmap -F 6469, an exception is thrown as below:

Attaching to process ID 6469, please wait...
Error attaching to process: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.111-b14. Target VM is 25.152-b11
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.111-b14. Target VM is 25.152-b11
    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.PMap.main(PMap.java:72)
    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.jmap.JMap.runTool(JMap.java:201)
    at sun.tools.jmap.JMap.main(JMap.java:130)
Caused by: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.111-b14. Target VM is 25.152-b11
    at sun.jvm.hotspot.runtime.VM.checkVMVersion(VM.java:227)
    at sun.jvm.hotspot.runtime.VM.<init>(VM.java:294)
    at sun.jvm.hotspot.runtime.VM.initialize(VM.java:370)
    at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:431)
    ... 11 more

It seems there is something wrong with my jvm version, but I can't find out why. I'm new to JVM, and I'd be grateful if someone could tell me why and how to deal with it.

simon s
  • 135
  • 1
  • 4
  • 15

3 Answers3

8

The target process (6469) runs under different version of JRE (1.8.0_152).

When running jmap or jstack in forced mode (-F), JDK version of the tool must be exactly the same as JDK of the target process.

See this answer for details.

apangin
  • 92,924
  • 10
  • 193
  • 247
0

I resolved this issue on ubuntu, after changing the java path.

Edit java path

sudo gedit /etc/profile

change the java path

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 (set the java path which java version you are using)

restart the system.

0

On Windows one can use psexec so we don't have to use the -F option. So you don't have to use the same exact jdk version for jhat and the for the java process.

This is useful when the jdk with the same exact version is not available. Say for instance, in a bigger organisation sometimes folks only update the jvm, but do not install the same jdk on the production system.

The psexec is part of the PsTools bundle. You can find them here. Here is what the command would look like:

F:\Programs\PSTools\PsExec.exe -s jmap.exe <pid>

Even with psexec one might need sufficient rights.

Tamas Rev
  • 7,008
  • 5
  • 32
  • 49