Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java set breakpoints programmatically

Is there any way to programmatically set breakpoints in Java?

Assume you have the filename with the source code line:

Test.java:123

How this can be done?

like image 712
100798 Avatar asked Jan 10 '12 00:01

100798


People also ask

How do you set a breakpoint in Java?

To define a breakpoint in your source code, right-click in the left margin in the Java editor and select Toggle Breakpoint. Alternatively, you can double-click on this position. The Breakpoints view allows you to delete and deactivate Breakpoints and modify their properties.

What is the command to set a breakpoint in JDB?

Breakpoints can be set in jdb at line numbers or at the first instruction of a method, for example: stop at MyClass:22 (sets a breakpoint at the first instruction for line 22 of the source file containing MyClass) stop in java. lang.

How do you debug Java code?

Run the program in debug modeClick the Run icon in the gutter, then select Modify Run Configuration. Enter arguments in the Program arguments field. Click the Run button near the main method. From the menu, select Debug.


1 Answers

The Eclipse IDE does not allow you to set a breakpoint from your java code.

However, it does allow you to set conditional breakpoints. With a conditional breakpoint, you can tell Eclipse to only break on a line after some Java expression evaluates to true. You can only tell it to break after some number of iterations. These modes should suffice for almost every usecase.

To enable a conditional breakpoint, right-click on a breakpoint and go to "Breakpoint properties".

like image 115
Laplie Anderson Avatar answered Oct 14 '22 22:10

Laplie Anderson