yunfan yunfan - 3 years ago 192
Java Question

Enable java remote debug in code

For example, we can enable java remote debug by adding following to command line.


But my application is running in yarn, I'm not sure which port is available.

So I want enable java debug in my code.

First I detect a available port and log in my program, then I can use this port to debug my application.

Answer Source

The address property specifies host (optionally) and port (only the port if host is left out). So address=5005 specifies the port 5005 in your case. If you want your program to wait until you connect your debugger, switch suspend=n to suspend=y.

Edit: Maybe I misunderstood your question. In case you want to enable debugging programmatically, this won't be possible as the debugging facility JPDA is not exposing a Java API nor any other way to start and stop it programmatically.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download