Chapter 4. Debugging

Let's face it: all but the most trivial programs have bugs in them. Eclipse provides a powerful debugger to help you find and eliminate those bugs quickly. This part of the book will give you a head start in understanding how to use the Eclipse debugger.

Running the Debugger

Running your program under the control of the debugger is similar to running it normally. Right-click on the file containing your main method (Hello.java) and select Debug As → Java Application. Or, if you have run or debugged the program before, just press F11 (or select Run → Debug Last Launched), or click on the Debug button () in the main toolbar.

Go ahead and try that now. What happened? The program ran to completion and sent its output to the Console view just as if you had run the class normally. You have to set a breakpoint to actually take advantage of the debugger.

Get Eclipse IDE Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.