1 Reply Latest reply: Nov 6, 2010 8:34 AM by jtahlborn RSS

    Enable remote debugging in a running JVM

      The well-known way to enable remote debugging is by launching the JVM with the arguments -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n (or variations of it).

      Is it possible to enable debugging after a program has been launched in a JVM without these arguments? In other words, after it's running, but without restarting it?
      For example, may this be achieved enabled from inside the program, maybe by calling methods that interact with the JVM?
        • 1. Re: Enable remote debugging in a running JVM
          yes, i believe it is possible. it's kind of obscure information, but it is basically similar to the ability of jvisualvm to dynamically attach to running java processes (in later versions of the jdk). this is enabled via some platform specific means of communication which dynamically starts the remote jmx agent within the running jvm (the last bit being the part that is relevant to your question). i don't know off-hand what incantations are necessary, but google should be able to find something about dynamically starting agents in running java vms.

          sure enough (and it seems to be related to the Attach API, which is what jvisualvm uses): http://osi.fotap.org/2008/06/27/dynamically-installing-agents-in-java-6/

          Edited by: jtahlborn on Nov 6, 2010 9:33 AM