简体   繁体   中英

Debug jar file in eclipse

I have a jar file which is having some issue and I would like to debug it.

I created the application on eclipse. During dev phase I have done debug but with the source code. I wanted to debug jar file to find out the reason of error ie it could be source code I have is different from jar file or some jar file issue.

Seems like you want to remote debug.

The use this command to launch your jar:

java -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=y -jar [JAR NAME HERE]

It should state something like :

Listening for transport dt_socket at address : 8001

And in eclipse, create a "Remote Java Application" debug configuration. The configuration is the only thing that matters as long as you have your project of interest open. Add the project[s] of interest that you would like to debug onto your source lookup path and set the port number to the configured address from the java launch command.

When you connect to your debug-enabled jar launch, your jar will halt execution and await debugger input upon hitting breakpoints. Just make sure you have the same version of the code in your jar and your eclipse.

You can use a java decompiler to that effect. I suggest jd ( http://jd.benow.ca/ ).

However, you would also need to include a realign feature ( http://mchr3k.github.io/jdeclipse-realign/ ) for the line numbers to match.

Of course, this can only work if debug information is included in the jar file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM