Informatik 1 Schmiedecke

Lab instructions X1a Introduction to the Eclipse Debugger


Objective: Start using the eclipse debugger.

These instructions are part of to lab X1 Eclipse.



  1. What is debugging?
  2. Breakpoints
  3. Start the debugger
  4. Stepping through
  5. Variable inspection
  6. Call stack
  7. Where do I find help


What is debugging?

Debugging means searching for semantic errors in a (basically) running program, which either crashes or prodeces some wrong results. Such errors that cannt be detected by the compiler, which only checks the language structure.


The idea is to watch the program running by stepwise execution and variable inspection. The tool to use for this is called a debugger, and we will begin to learn how to use eclipse's debugging tool.



Realistic programs are too long to step through from the beginning to the end, so the first thing to do is to mark the area of interest by setting stop signals, called breakpoints. When you start the debugger, it will run the program until the first breakpoint. From you can step through as far as you like, and then "resume" running, which takes you quickly to the next breakpoint. So, before you can start debugging, you need to set a breakpoint. In eclipse, you can set (and reset) a breakpoint by double clicking the left margin of the corresponding line. A breakpoint is shown as a little blue cirlce. Begin by setting a breakpoint at the first line of your main method.


Start the debugger

Start the debugger by choosing "debug as" instead of "run as". Repeated debugger calls can be made by clicking the green bug ican instead of the green arrow icon. Eclipse will ask you whether you want to open the debug perspective choose "yes".






run debugger


inspection tabs


debug controls


The Debug Pesrpective 


Stepping through


When you start the debugger, it will run the program to the first breakpoint and stop there, highlighting the line in the source code. Now you can use the debug controls to execute your program stepwise. If the current line contains a method call, "step over" means execute the entire method and stop afterwards, "step into" means call the method and execute it stepwise. If the current instruction is a simple statement, both controls do the same thing. When you have seen enough, use the "resume" control to rush to next breakpoint, which may be the same one if you are inside a loop, or use the stop control to exit program execution.


Hint: If your program does not seem to do the next step, it might be waiting for input ;)



Variable inspection





The top right pane contains three tabs that inform you about the current state of your program: The breakpoints tab lists all breakpoints that you have set and allows you to activate / deactivate them during debugging.


The variables tab is the most frequently used tab: it will display a list of all currently visible variables and their values. If you right click on a vraible, you can even change its value.


The expressions tab displays the set of variables and expressions that you have explicitly chosen for watching: In the source code, mark a variable or exppression, right click on it and choose "watch" it will then be displayed in the expressions tab, whenever it is visible in the program. You can change these values, too, by right clicking on them.


Call stack


The top left pane displays the current call stack we will learn about it later.


Where do I get Help?

Use the Help Menu, or find tutorials with google.



Google seems to know a lot about java programming even strange error messages will lead you to forums discussing solutions...
When you are in the lab, you will be surrounded by people having similar problems. Some of them might already have solved yours....

: Ilse Schmiedecke 2008 For questions and comments contact