Java Debugging

java

https://blog.codecentric.de/en/2013/04/again-10-tips-on-java-debugging-with-eclipse/
http://weblogic.sys-con.com/node/169364
http://www.jacoozi.com/index.php?option=com_content&task=view&id=119&Itemid=134
http://download.oracle.com/javase/1.3/docs/tooldocs/solaris/jdb.html
JDebugTool
JSwat
http://www.digilife.be/quickreferences/PT/Java%20debugging.pdf
http://www.lambdacs.com/debugger/
http://www.ibm.com/developerworks/library/os-ecbug/

Jikes
JDB
javadt
JProbe

You can compile your program with certain compiler options that instruct the compiler to generate symbolic information in the object file. If you use the javac compiler to build your code, use the -g compiler option. This option lets you examine local, class instance, and static variables when debugging. You can still set breakpoints and step through your code if you do not compile your classes with the -g option. However, you will not be able to inspect variables.

How can we configure Eclipse to debug Java application?

  1. Click on the name of the project
  2. Click on Run -> Debug Configuration
  3. Click on Remote Debugging

See the weblogic-debug page for details.

How can we configure Eclipse to start debugging when we hit an exception?

This may be handy when we need to debug an application when an exception is thrown but stack trace is not logged in the log file. To configure Eclipse to start debugging when an exception is thrown:

  1. Switch to the Debug perspective.
  2. Click on the Breakpoints tab
  3. Click on the icon with the letter J and the exclamation mark
  4. Scroll down to find "Exception" from java.lang and click on it
  5. Click the OK button

How can we debug a command-line Java application?

Append:

-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y

to the command that you use to run your Java application. The suspend=y flag ensure that that application will not start running until Eclipse connect it on speicified debug port. Put the above string before the -jar option, and possibly before other options as well. You may have to change the port number mentioned above and change the port number in your Eclipse to get this to work. We must use the same port number in both places.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License