首页 > 技术文章 > jvm本地调试jdk1.8本地调试

zxg-blog 2020-08-13 19:26 原文

1、首先要查看jvm信息,在java服务启动时是需要指定参数的,我这个是springboot服务jar包启动方式;命令如下:

nohup java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=172.xxx -Dcom.sun.management.jmxremote.rmi.port=9011 -jar tttest.jar &

2、使用jdk自带工具 VisualVM ,方法打开cmd命令窗口,输入jvisualvm.exe

3、输入上面命令后自动打开窗口

如果时本地运行的java服务,直接打开本地的那个虚拟机即可,如果时远程的则需要使用远程工具,右键添加主机,选择格式是:ip:port   。然后再右键刚才添加的主机,选择添加jmx连接。

如果一切顺利就打开了查看页面。

4、对于上面的命令参数有个说明

配置功能备注
-Dcom.sun.management.jmxremote.authenticate connection authenticate true / false
-Dcom.sun.management.jmxremote.port jmx connection remote port 1~65535
-Dcom.sun.management.jmxremote.local.only remote can connection true / false
-Dcom.sun.management.jmxremote.ssl enable ssl connection true / false
-Djava.rmi.server.hostname multi eth choose ip / domain
-Dcom.sun.management.jmxremote.access.file remote access roles file path
-Dcom.sun.management.jmxremote.password.file remote authenticate file when auth config enable file path

根据名称,可以猜个大概意思。希望各位在使用时一切操作顺利。

 

推荐阅读