'Connect to JVM for debugging that has been spawned by a Python script

I have a Python code, which I run with IntelliJ. The Python code will execute a java command, which will eventually spawn a JVM. The Python and JVM communicates using Py4J and custom sockets. How can I connect to the JVM for debugging purposes using IntelliJ?



Solution 1:[1]

You execute the java command which spawns a JVM with the debug arguments.

I.e. -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044.

Then in the IDE you create a new remote connection. In fact, when you go about creating a new one, when you specify host and port it already gives you the arguments, such as:

Command line arguments for running remote JVM:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Laurentiu L.