I'm trying to use the jmap
command on my CentOS
server but it keeps telling me that the command was not found even though I have the JDK installed.
Here is the output of command java -version
:
java version "1.7.0_25"
OpenJDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
How can I fix this issue?
You should be able to find jmap in the java-1.8.0-openjdk-devel-debug, or java-1.7.0-openjdk-devel-debug, or java-1.6.0-openjdk-devel-debug packages on Redhat/Centos. To install it, run the following as root:
yum install java-1.8.0-openjdk-devel-debug
For completeness, here's the command to check which packages include jmap:
yum whatprovides '*/jmap'
Here's a sample output:
1:java-1.6.0-openjdk-devel-1.6.0.37-1.13.9.4.el7_1.x86_64 : OpenJDK Development Environment
Repo : updates
Matched from:
Filename : /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.37.x86_64/bin/jmap
1:java-1.7.0-openjdk-devel-1.7.0.91-2.6.2.3.el7.x86_64 : OpenJDK Development Environment
Repo : base
Matched from:
Filename : /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64/bin/jmap
1:java-1.8.0-openjdk-devel-1.8.0.65-3.b17.el7.x86_64 : OpenJDK Development Environment
Repo : base
Matched from:
Filename : /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/bin/jmap
1:java-1.8.0-openjdk-devel-debug-1.8.0.65-3.b17.el7.x86_64 : OpenJDK Development Environment with full debug on
Repo : base
Matched from:
Filename : /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64-debug/bin/jmap
1:java-1.8.0-openjdk-devel-debug-1.8.0.65-3.b17.el7.x86_64 : OpenJDK Development Environment with full debug on
Repo : @base
Matched from:
Filename : /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64-debug/bin/jmap
My situation was a little strange (running inside the openjdk:8-jre
Docker image), but this combination worked
cat /etc/debian_version # 8.6
apt install -t jessie-backports openjdk-8-jre-headless ca-certificates-java
apt-get install -f -y openjdk-8-jdk-headless
apt-get install -f -y openjdk-8-dbg
The following worked for me:
sudo apt-get install openjdk-8-jdk openjdk-8-dbg
the java path must be in the "PATH" systemproperty.
$JAVA_HOME/bin
OpenJDK on centos doesn't include the jmap utility. test on another platform or use the jhat java_pid1234.hprof
command to examine the dump after the fact on another platform.
jhat can be slow to run on large dumps and even run out of memory! I use jhat -port 7000 -J-mx2048m java_pid1234.hprof
so you'll need plenty of ram on your computer.
it doesn't come default with JRE -- you should be able to install it with below command
yum install java-1.8.0-openjdk-devel-debug
I found that on my system (elasticsearch container) it is excluded:
$ grep exclude /etc/yum.conf
exclude=java-1.8.0-openjdk*
If I comment it out then I can see and install this package with yum install ...
for Debian "buster" - 10.3 -
cat /etc/debian_version # 10.3
echo "deb http://ftp.us.debian.org/debian sid main" > /etc/apt/sources.list.d/buster.list
apt-get update && apt-get install -f -y openjdk-8-jdk-headless openjdk-8-dbg