Search code examples
javaeclipsedebuggingjarremote-debugging

How to debug a jar in eclipse when run with this command java -jar target/TextSecureServer-1.22.jar server config/development.yml


I am editing SecureServer Project in eclipse but I am executing it using below command in separate command line

java -jar target/TextSecureServer-1.22.jar server config/development.yml

How can I attach eclipse debugger to this running jar file?


Solution

  • A running Java application which did not include the JVM flags to specify debug mode cannot be attached to a debugger. You will need to restart the application specifying the appropriate arguments. You will find sufficient information on these command line options

    For Java 5 and above

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

    For old versions

    -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000
    

    Note : The documentation does say :

    A process to be debugged need not have been started in debug mode(ie, with -agentlib:jdwp or -Xrunjdwp)

    But this could be something thats not available yet. You can watch a running application using a tool like processexplorer to see that there are no default listen ports when you run a java application without the arguments.