如何动态打开verbose class
发布网友
发布时间:2024-10-06 09:43
我来回答
共1个回答
热心网友
时间:2024-11-04 08:18
Linux/Unix: ps -ef | grep java
1 public MBeanServerConnection getMBeanServerConnection(long pid)
2 {
3 MBeanServerConnection serviceConnection = null;
4 VirtualMachine vm = null;
5 try
6 {
7 vm = VirtualMachine.attach(String.valueOf(pid));
8 String connectorAddress =
9 vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS);
10 if (connectorAddress == null) {
11 String agent = vm.getSystemProperties().getProperty("java.home") +
12 File.separator + "lib" + File.separator + "management-agent.jar";
13 vm.loadAgent(agent);
14 connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS);
15 }
16 if(connectorAddress == null)
17 System.exit(1);
18 serviceConnection = getMBeanServerConnection(connectorAddress);
19 }catch(Exception e){}
20 return serviceConnection;
21 }
2:remote management的listening address及listening port
为了启用remote managed port,我们需要在服务器的启动脚本中加入如下内容,如果你觉得不做验证、non-ssl很不爽,你可以使用SSL及password file做认证.
set JAVA_OPTIONS=-Dcom.sun.management.jmxremote.port=9192 %JAVA_OPTIONS%
set JAVA_OPTIONS=-Dcom.sun.management.jmxremote.authenticate=false %JAVA_OPTIONS%
set JAVA_OPTIONS=-Dcom.sun.management.jmxremote.ssl=false %JAVA_OPTIONS%