File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes How to set breakpoint programmatically under Eclipse? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "How to set breakpoint programmatically under Eclipse?" Watch "How to set breakpoint programmatically under Eclipse?" New topic
Author

How to set breakpoint programmatically under Eclipse?

Jane Jukowsky
Ranch Hand

Joined: Mar 28, 2009
Posts: 145
I have my own ErrorHandler class with a method breakpoint() that does nothing but beg user to "set breakpoint here". It's a bit like a low-tech virus from an old joke, that asks you to delete all your files and forward it to all your friends. Any way I can make Eclipse set a breakpoint, from my Java code?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

No. For one thing, what would it do if you weren't running under a debugger? For another thing, the debugger client is what works with breakpoints, and it's typically running in a different VM which may be on a different computer, and it might not even be a Java program at all, since the low-level debugger communications channel involves text commands. Meaning that if I wanted to write a Java debugger in Python, I could do so.

In the case of Eclipse, specifically, you might be able to create an Eclipse plug-in that talked to the Eclipse debugger client, but that seems like a lot of work. It's easier just to throw some sort of Breakpoint exception and tell the Eclipse debugger to halt on breakpoint. I often do that to catch NullPointerExceptions in the act, but any Exception will do, including one you make up for just that purpose.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jane Jukowsky
Ranch Hand

Joined: Mar 28, 2009
Posts: 145
Tim Holloway wrote:No. For one thing, what would it do if you weren't running under a debugger?


I don't know.. recover gracefully? I did it in 1999 for VisualAgeForJava, it took 3 lines of code and worked fine.

For another thing, the debugger client is what works with breakpoints, and it's typically running in a different VM which may be on a different computer, and it might not even be a Java program at all, since the low-level debugger communications channel involves text commands. Meaning that if I wanted to write a Java debugger in Python, I could do so.


You are right in principle, but I had specified Eclipse.

In the case of Eclipse, specifically, you might be able to create an Eclipse plug-in that talked to the Eclipse debugger client, but that seems like a lot of work.
Is it? I did not know that, thanks! I was hoping it would be as easy as Visual Age.

It's easier just to throw some sort of Breakpoint exception and tell the Eclipse debugger to halt on breakpoint. I often do that to catch NullPointerExceptions in the act, but any Exception will do, including one you make up for just that purpose.


That's close to what I am doing now, but I "clear all breakpoints" often, and I start with a clean workspace often enough, and will potentially have other users do the same; so it's not ideal.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set breakpoint programmatically under Eclipse?
 
Similar Threads
How to debug using Eclipse?
Eclipse breakpoint window error
Eclipse breakpoint in class/jar with no source
Problems passing data into file from JTable
I need to step thru another war that I link to...