advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Reverse Engineering to Peek at Java Class Source Code
Graphical Java IDEs allow breakpoints to be set visually, such as by clicking on a line of source code (which then turns red to indicate it is a breakpoint), and to change the value of variables during program execution. What others features that currently in your debugger would be useful to you?
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 3/5 | Rate this item | 2 users have rated this item.
 

Use the Java Debugger to Determine the Causes of Errors

Although the Java Virtual Machine frees programmers from many low-level tasks like garbage collection, it can't protect them from mistakes in design and logic. This article explores the Java Debugger, which you can use to trace through a running program and determine the causes of any errors. 


advertisement
Debugging is an art that every successful programmer needs to master sooner rather than later. The sad truth is that program bugs appear almost as soon as you start coding. Although a Java compiler always will detect syntax errors, often code that is syntactically correct is not logically correct. These sorts of problems may require the help of a debugger.

Sun's Java Development Kit (JDK) includes a debugger called JDB (Java Debugger), a command-line application under which you can execute the programs you need to inspect. With JDB, you can inspect variables while a program is running, set breakpoints to halt the execution of a program at a certain point, and execute code line by line (known as single-stepping). You can see just how the contents of variables change after each statement of program code, and you can precisely trace the execution of a program--even as it branches to other functions or iterates through loops.

JDB can be used to debug graphical programs and applets as well. An important thing to note, though, is that the programs you debug must be compiled with the -g flag. This causes the Java compiler to insert additional debugging information into the resulting Java class file. (See the Sidebar: Reverse Engineering to Peek at Java Class Source Code for an examination of a command that disassembles Java classes so you can explore the original source code behind it.)

  Next Page: A Sample Debugging Session
Page 1: IntroductionPage 3: Breakpoints: The Most Useful Debugger Feature
Page 2: A Sample Debugging SessionPage 4: Effective Debugging as a Software Engineering Skill
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs