Debugging the NetBeans Platform

Once you've set up the NetBeans Platform sources as your NetBeans Platform, you're able to debug the NetBeans Platform itself. That's an occasional question (certainly not a frequent question) on the mailing list and in NetBeans Platform courses: "Is it possible to debug the NetBeans Platform?"

Well, here's how:

  1. Firstly, set up the NetBeans Platform sources as your NetBeans Platform.

  2. Now, open into NetBeans IDE the NetBeans module where you'd like to place a breakpoint. That in itself is the hardest part of this task. I.e., you know you want to debug the NetBeans Platform, but have no idea where to place your breakpoint.

    One way to figure that out, from 7.1 onwards, is to take a visual snapshot of the NetBeans Platform and then analyze that snapshot in NetBeans IDE. To do this, right-click a module that you've set as using the NetBeans Platform sources as your NetBeans Platform and then choose Debug. The application, i.e., the NetBeans Platform, including your custom module, starts up and you'll see this, i.e., NetBeans IDE in debug mode together with your NetBeans Platform application:

    Notice there's a new toolbar button (new in NetBeans IDE 7.1) that resembles an orange camera. Click that button and the IDE creates a visual snapshot of the running application, which in this case is the NetBeans Platform. When you click components in the visual snapshot, the Navigator and Properties window display information about the related GUI component:

By clicking the above components, you can end up identifying the component you'd like to debug and even the module where it is found. Open that module. Set a breakpoint on the line of interest. Right-click the module again and choose Debug. A debug session starts and when the breakpoint is hit, the Debugger in the IDE will open and there you can step through the NetBeans Platform sources.


Of course the GUI snapshot button is only helpful if what you are debugging is the behavior of some GUI component. Often things will be more abstracted so that the code you want to debug is not in the same class or even the same module as the code which physically creates the GUI.

Posted by Jesse Glick on November 28, 2011 at 04:30 AM PST #

Hi Geertjan,

The post about debugging is nice.

I would like to know whether there is any option to set a flag whenever the state of a boolean field changes for true to false or vice-versa.


Posted by Nigel Thomas on February 14, 2013 at 11:51 PM PST #

In the above question I would like to clarify that I am using NetBeans 7.0

Posted by Nigel Thomas on February 15, 2013 at 01:51 AM PST #

Hi Geertjan. Thanks for the write up. I'm trying this out right now with NetBeans 8.0, but I'm running into a "Build Failed" when I try to debug a module from the sources. I've downloaded the ZIP archive of the build version of the IDE I'm using, which is After running the ant command referenced in the other post and registering the build as a Netbeans Platform, I open e.g. tomcat5 project. Then I click on Debug. NetBeans starts compiling, and eventually fails with this:

sh: 0: Can't open /home/kuw/Java/netbeans-source/netbeans-8.0-201403101706-src/nbbuild/netbeans/bin/netbeans
/home/kuw/Java/netbeans-source/netbeans-8.0-201403101706-src/nbbuild/templates/projectized.xml:402: The following error occurred while executing this line:
/home/kuw/Java/netbeans-source/netbeans-8.0-201403101706-src/nbbuild/build.xml:925: The following error occurred while executing this line:
/home/kuw/Java/netbeans-source/netbeans-8.0-201403101706-src/nbbuild/build.xml:1000: exec returned: 127
BUILD FAILED (total time: 2 minutes 48 seconds)

Have I missed a step? After clicking Debug and all of the compile messages, the project errors disappear and everything seems ok with the module. But it just won't run (Debug).

Please help. Thanks.

Posted by guest on July 14, 2014 at 04:04 PM PDT #

Hi Greertjan - very helpful. I too am also running into the same issue that guest above is hitting. I'm building from mercurial head source. and get the same error:

jim@jim-VirtualBox:~/projects/nb_main/nbbuild$ ( export ANT_OPTS="-Xms512m -Xmx1024m"; ant -v tryme ; )

[.... whole lot of output ....]

[property] Loading Environment env.
Property "env.NBDISPLAY" has not been set
[available] Unable to find /usr/lib/jvm/java-7-openjdk-i386/jre/lib/amd64
[exec] Current OS is Linux
[exec] Setting environment variable: DISPLAY=:0
[exec] Executing 'sh' with arguments:
[exec] '/home/jim/projects/nb_main/nbbuild/netbeans/bin/netbeans'
[exec] '--jdkhome'
[exec] '/usr/lib/jvm/java-7-openjdk-i386'
[exec] '--userdir'
[exec] '/home/jim/projects/nb_main/nbbuild/testuserdir'
[exec] '-J-Dnetbeans.full.hack=true'
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
[exec] sh: 0: Can't open /home/jim/projects/nb_main/nbbuild/netbeans/bin/netbeans

/home/jim/projects/nb_main/nbbuild/build.xml:1000: exec returned: 127
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(

Total time: 1 second

Posted by guest on December 12, 2014 at 02:05 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« May 2016