

A breakpoint is a way to tell the debugger from where you want to take control of your code. To take manual control of your program at the time of execution you need something called a breakpoint.

However, you want it to halt when it enters the array and from there you want to run every line of the code manually. If you run your code directly at this point, it will run completely and halt when an exception is thrown. Now as we have the debugger, let’s debug. Console: This is where you can see the execution happening.From here you can perform advanced operations on breakpoints such as defining conditions on them. Breakpoint: In this section, you can view and change breakpoints (explained further).By right-clicking on the variables displayed here, you can do multiple operations on them like change them or view their data type, etc. Variables: This section is where you can view the variables and how their state is changing during execution.Class: This is the class that you want to debug.Debug window: Right next to the project explorer the debug explorer is opened, in which the class being debugged is displayed.The debug perspective will show the following window: Click on the first option in the “Open Perspective” and click on open. Let’s see what happens when you launch this perspective. You can launch the debugger through the perspectives in Eclipse.ĭebug is the first view available in the list of perspectives. There are multiple ways to launch the debugger on your code. The same logic can be applied to complex codes as well. However as this tutorial is more about the debugger, we have chosen this simple code. In the example we are using, you may be able to understand the issue just by viewing the exception, as the array size is less than the number of times the for loop is running this exception is being thrown.

Debugging will let you see how the code enters the “for loop” for every iteration and shows you why it is throwing an error after printing a few options. ("This is my first code2") ĭebugging helps for such exceptions. However, if you have runtime exceptions, then they may not be highlighted in the code, instead, when you run the code, your program will fail due to this exception. Compiler errors are highlighted in the code itself in the Eclipse IDE and with compile-time errors, you cannot proceed to run your program. That means you are able to see the execution of each line of your code and stop at any line of the code and analyze the code, the variables, and the values these variables carry at the time you have halted the execution.ĭebugging is used extensively to find runtime errors in your code. Debugging is a technique that is used to see your code execute line by line.
