0% found this document useful (0 votes)
49 views

Java Debugging With Visual Studio Code

The document discusses debugging in VS Code by explaining what debugging is, how to run a program in debug mode, set breakpoints, use stepping commands, and watch variable values during debugging.

Uploaded by

bmwli
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Java Debugging With Visual Studio Code

The document discusses debugging in VS Code by explaining what debugging is, how to run a program in debug mode, set breakpoints, use stepping commands, and watch variable values during debugging.

Uploaded by

bmwli
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Eastern International University School of CIT

JAVA DEBUGGING IN VS CODE


1. What is debugging?

Debugging allows you to run a program interactively while watching the source
code and the variables during the execution.

Debugging is a fundamental skill of a programmer. The main purpose of debugging


is to find errors in the program, in addition, it also helps the programmer better
understand how the program works.

A breakpoint in the source code specifies where the execution of the program
should stop during debugging. Once the program is stopped you can investigate
variables, change their content, etc.

Here are some quick tips and tools that will help you get started quickly with
debugging your Java project.
2. Run a program in debug mode

• On menu bar -> Run -> Start Debugging.

• Right click on the class contain method main() -> Debug Java.

CSE 102 – Introduction to Programming


Eastern International University School of CIT

3. Breakpoints

A breakpoint is a signal that tells the debugger to temporarily suspend execution


of your program at a certain point in the code.
To define a breakpoint in your source code, Hover the mouse over the line and click
to put the breakpoint.

CSE 102 – Introduction to Programming


Eastern International University School of CIT

4. Stepping commands

The Eclipse Platform helps developers debug by providing buttons in the toolbar
and key binding shortcuts to control program execution.

• Continue (F5): executes the current statement and jumps to next breakpoint
or to the end of program.
• Step Over (F10): Step over the call.
• Step Into (F11): Step into the call.

CSE 102 – Introduction to Programming


Eastern International University School of CIT

• Step Out (Shift + F11): executes the current statement and returns to the
place called this method.
• Restart (Ctrl + Shift + F5): restart debugging.
• Stop (Shift + F5): terminate debugging.

5. Watching the values of variables in the debug

If a Breakpoint is encountered, the program will stop for you to control and
monitor. As you can see, the program will stop at Breakpoint at line number 9:

CSE 102 – Introduction to Programming


Eastern International University School of CIT

6. Adding variable values during debugging


For example: start the above demo program, trying to add some variable and
watch the value of these variable by doing as follow:

--------oooooENDooooo--------

CSE 102 – Introduction to Programming

You might also like