For example, we can enable java remote debug by adding following to command line.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
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.