Identify Java jdwp Debugger Assigned (Ephemeral) Port

后端 未结 2 684
感情败类
感情败类 2021-01-03 03:18

I am using the following JVM parameters to start-up a JVM with the hostpot debugger.

-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=0
2条回答
  •  無奈伤痛
    2021-01-03 04:02

    From within VM:

        Properties props = sun.misc.VMSupport.getAgentProperties();
        System.out.println(props.getProperty("sun.jdwp.listenerAddress"));
    

    From outside application:

        VirtualMachine vm = com.sun.tools.attach.VirtualMachine.attach(PID);
        try {
            Properties props = vm.getAgentProperties();
            System.out.println(props.getProperty("sun.jdwp.listenerAddress"));
        } finally {
            vm.detach();
        }
    

    Both are not a part of a standard. Applicable only to OpenJDK / Oracle JDK.

提交回复
热议问题