Sunteți pe pagina 1din 4

Add/Remove Breakpoints

You can add a breakpoint by double-clicking in the bar to the left of the code (Figure 1).

To remove a breakpoint, double-click on it.
Alternatively, if you right-click on the breakpoint a pop-up menu will appear. Select Toggle
Breakpoint.



Start Debugger
Start debugging by pressing the button with the little green bug ( ).
The code can take a while to start, and runs a bit slower than normal. Once the code reaches
a breakpoint it will stop progressing.
The Confirm Perspective Switch will appear asking whether you want to change to the
debugger perspective. Select Yes to change the perspective.



Area 1: You can find all current variables under this section. If you go to the variables
starting with m, youll find all the variables you will need. There are many variables here that

you may not understand, for now you need only be concerned with the ones defined in
TheGame.java.

Area 2: This is where the code is.

Area 3: This logs all errors, warnings, and messages. If something bad happens and theres a
bug you dont understand, you can copy the messages from here and tell us about them in
the comments on the course. The errors to do with the game will have the name
uk.ac.reading.sis05kol.mooc in the Application column.

Area 4: Clicking the different methods will take you to the correlating code in the main
section. Its a fast and easy way to navigate the code!
Debug Commands
You will see that the ball does not move yet, and only the Y position is set. This is because the
green line in the code has not run yet. If you press F6 (Step Over shown in ) to
execute the statement then you should see a new value for the X position.
Click the Resume button to continue running the code. (Alternatively you could execute
each statement manually by using F6 for each line). The code will stop at breakpoints you
have inserted. For instance if you have a breakpoint inserted in the onDraw method, the code
will stop every time the app is drawn on the screen, which is almost all the time



Break Debug Connection
Use Disconnect button to break the debug connection. Once you have done this, the code
will run on the phone (or emulator) without the debugging function interfering. It will also
run much faster.
Should you wish to explore more, you could check out this external
Java Debugging with Eclipse Tutorial by Lars Vogel
There are of course many other tutorials available online.

S-ar putea să vă placă și