Open In App

How to Debug a Java Project in Eclipse?

Last Updated : 24 Dec, 2022
Like Article

Every Java developer needs to work in Debug mode to resolve the errors. Experienced Java developer already knows how to debug the code but if you are new as a Java developer this article will cover the topics which help to debug the code faster in eclipse and also use the “Debug Mode” efficiently and efficiently. Let’s understand some terms to begin. 

What is Debugging?

Debugging is one of the broadest topics in Software Engineering. It is a process to find subtle and remove bugs, and errors, and to understand the flow of the code as well. It is a must-have skill for all Java developers because debugging can help in locating the bugs which are not visible during code reviews. Let’s discuss the steps to debug the code in eclipse.

Step by Step Implementation

Step 1: Start with setting Breakpoints 

First, we need to set breakpoints in the code to stop the execution at your desired location. While running the program in debug mode it will temporarily stop execution at a particular point in the code. So, there are some ways to set breakpoints in code. 

  • First, is to put the cursor on a line in code which you want to set as a breakpoint then press Ctrl+Shift+B.
  • Second, is to double-click on the left margin or right-click in the editor and select “Toggle Breakpoint.


You will see a blue dot will appear next to that line. 


Step 2: Activate Debug Mode

Now to debug the project have different ways in Eclipse.

First, right-click on the project which you want to debug and select “Debug As” then “Java Application”.


Eclipse asks you want to switch to the Debug Perspective once the compiler reached the first breakpoint. Like the below image


Once you click on Switch, you will see Debug Mode in eclipse. 


Second, on the right corner of the eclipse editor have an Icon debug double Click on it.


You will observe that debug mode is activated. Like the below image.


On the right side, in the “Breakpoints” section you can see a list of all the Breakpoints which has been set for you.

Step 3: Control the flow of Execution

In the toolbar of Eclipse editor appears several buttons for controlling the flow of execution of the program.


To control the flow of execution eclipse provide the most commonly used buttons are:

Button Name  Short-Cut key Purpose
Resume F8 Execution of the program until the next breakpoint is reached.
Terminate  Ctrl+F2 To stop the execution of code.
Step Into F5 Executes the current line of code and goes to the next line of code. 
Step Over F6 Executes the current line of code and goes back to the previous line. 


For every Java Developer having good debugging skills is necessary. it can be got by practice there are not any particular techniques to learn and get the debugging skills for that you need to spend more time and learn the different views of debugging this article is for beginners who are just starting their journey as Java developers. Hope this article helps and start your debugging journey.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads