Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetBeans and stop/break on all Exceptions?

I'm using NetBeans as my IDE for developing Android.

However, when I get an exception, Netbeans does not break on the exception as I expect it to.

I have checked the box "Stop on uncaught exceptions" that can be found in Options --> Java Debugger --> Stop on uncaught exceptions but that doesn't help.

Furthermore, where can I see the actual exception message? I don't see anything. I have no clue where and when an exception occurs, just that it does occur.

I've read some on the netbeans.org site about a bug in 6.9.1 that was fixed, but it doesn't seem to be fixed in 7.0 that I have.

The debugging window doesn't say anything useful at all, gives some form of stack trace that is pointless as it doesn't specify any of my own code.

I switched from Eclipse because that IDE sucks, NetBeans is much leaner, but the debugging needs to be fixed to be useful.

like image 964
Ted Avatar asked Aug 31 '11 21:08

Ted


People also ask

How do I remove all breakpoints in NetBeans?

Once these breakpoints are set, these can be removed by toggling off (Right-click and select Toggle Breakpoints or just highlight and use CTRL-F8).

What is line breakpoint in NetBeans?

Breakpoint - a line of code where you want to "pause" the execution of a program. For example, if you want to pause the program at line 14, place a breakpoint there. Continue - will continue the execution of the program until the next breakpoint or until the program terminates.

How fix NetBeans unexpected exception?

Easy fix. To fix the error, you need to uninstall JAVA 14 and install Java 13 and rerun NetBeans installer.


1 Answers

I have this problem when I use netbeans too. To get the exception message, I use try-and-catch. In the catch() statement, call a function that contains some code and put a breakpoint on it. Then when the exception is given your breakpoint in the catch statement will be called and you can read the information (error message, stack, etc.) from the Exception obect.

try
{
    // Doing something here
}
catch (Exception e1)
{
    // This is called when an exception occurs
    doSomething();   /// Put breakpoint here
}

UPDATE:

I am not sure if this will work for android but you could try entering a "New Breakpoint". When entering a new breakpoint to break on an exception, you need to know the exact package/class exception name. For example, if you want to catch a NullPointerException, then you go to Debug >> New Breakpoint to create a New Breakpoint and enter java.lang.NullPointerException into the Exception Class Name field in the Breakpoint Properties dialog. Choose whether to break on caught, uncaught or both, exceptions and it will hit a breakpoint if that type of exception ever occurs in the class/project.

like image 101
A. Abiri Avatar answered Sep 23 '22 13:09

A. Abiri