Search code examples
eclipsedebuggingjdb

Invoking debug session in Eclipse outside Eclipse


How to run debugging session in Eclipse but to invoke it outside Eclipse (instead of doing Run->Debug I want to invoke some process (maybe jdb?) that will start debug in Eclipse). Is that possible?


Solution

  • As illustrated by this thread, it is possible through remote debugging (see remote debugging).
    I.e: it won't automatically launch Eclipse for you. You have to launch an Eclipse session and listen to the port used for remote debugging.

    Well I just tried running a program from an Ant buildfile and then connected to it with Eclipse..worked great.
    My test:

     <project default="remote">
      <target name="remote">
    
       <java classname="B" fork="true">
        <classpath>
         <pathelement path="bin" />
        </classpath>
        <jvmarg value="-Xdebug" />
        <jvmarg value="-Xnoagent" />
        <jvmarg value="-Djava.compiler=NONE" />
        <jvmarg
     value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" />
       </java>
    
      </target>
     </project>
    

    I launched the Ant build outside Eclipse and tried with address=8000.
    [...]. Also, since my app takes long to start I connected Eclipse pretty much after starting Ant. It shows some threads and picked up.