最近在学习 《深入理解java虚拟机》,第四章的JDK监控和故障处理工具,讲到了许多的命令,例如jps,jstat,当我在终端输入 jps 、jstat这些命令时,总是提示:
Unable to locate an executable at “/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/jps“
具体如下:
xuxiangyangdeMacBook-Air:bin XXY$ jps
Unable to locate an executable at "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/jps" (-1)
我打开提示的”/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/jps”文件夹,发现根本没有jps这个文件
然后我就灵机一动,把java安装目录下的bin文件里所有文件 复制到提示的“/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin”目录下。注意:同名的文件选择跳过,不要替换,不然就玩坏了。。。。然后在终端再次输入 :jps
这次又提示如下:
xuxiangyangdeMacBook-Air:bin XXY$ jps
错误: 找不到或无法加载主类 sun.tools.jps.Jps
这下就好办了,书上说:JDK监控和故障处理工具大多数是jdk/lib/tools.jar类库的一层包装,然后我就把java安装目录下的lib文件夹(lib文件夹和bin文件夹同级)里的tools.jar这个文件复制到了“/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib”目录下
然后我又在终端输入:jps
终于成功了 运行如下:
xuxiangyangdeMacBook-Air:bin XXY$ jps
22801 Jps
22610 AppMain
22611 Launcher
18853
22581 RemoteMavenServer
22567
再测试一下 jstat命令,输入:jstat -gc 22610 250 20
xuxiangyangdeMacBook-Air:bin XXY$ jstat -gc 22610 250 20
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 216239.8 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 220652.4 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
12800.0 12800.0 64.0 0.0 323584.0 220652.4 52736.0 29881.9 40064.0 39233.7 4992.0 4789.5 14 0.380 2 0.207 0.587
大功告成