In the previous blog post, some areas remained unexplored. Specifically, how to observe the values of variables with versions of the IDE that don’t include debug information. In this guest post by Robert Bracko (robert [dot] bracko [at] vip [dot] hr), he describes his experiences with building the NetBeans IDE source code to overcome this obstacle.

Step 1: Building NB sources

Create local disk folder C:\nb6_9_1

Download NB platform sources (netbeans-6.9.1-201007282301-src.zip) and extract it into C:\nb6_9_1\src

Download NB binaries (netbeans-6.9.1-201007282301-ml-javase.zip). This step is necessary for getting the appropriate Ant builder. Extract only netbeans\java\ant into C:\nb6_9_1\ant. Result of that operation should be that C:\nb6_9_1\ant contains ant subfolders bin, etc, extra, lib…

Open command shell and change directory to C:\nb6_9_1. Execute buildenv.bat. Then change directory to NetBeans source which is to be built (C:\nb6_9_1\src). Execute ant (without any cmd-line params). Please be patient; depending on your machine power, the process can take up to hour!

As a result of above-described procedure, new folder is created: C:\nb6_9_1\src\nbbuild.

General notes

For some reason, path of Ant installation directory must not contain spaces!

If building for the first time, disable Windows Firewall because for some reason it prevents Ant from downloading jars from web.

Possible build error “java.lang.OutOfMemoryError” can be overridden by following batch command: set ANT_OPTS=-Xmx1g

Note on building NB 6.9.1 sources:

During build process, you will probably encounter the following error:
C:\nb6_9_1\src\o.jruby.distro\unpatched_source\jruby-1.5.0\build.xml:1141: Java returned: 1

Step 2: Debugging specific NB platform and/or NB module that was developed for that platform

Open your development IDE (in my case, it’s NB 7.3).
There are two possible ways to debug NB module that was developed for specific NB target-platform (in our case, it’s for NB 6.9.1). I prefer the first one ("Adding target platform through NetBeans Platform Manager") because it’s not necessary to install NBM inside target-IDE.

Open your NBM project.
The following is important! Open Project Properties > Libraries and adjust the field “NetBeans Platform” to hold the value nb691!

Set the breakpoint inside your NBM code.

Optionally, you can set the breakpoint inside NB platform source code. For instance, let’s imagine that your NBM uses functionality of NB class AbsoluteLayoutSupport and you want to check the interaction. Make a Windows file-search inside the folder C:\nb6_9_1\src. That results in containing folder C:\nb6_9_1\src\form\src\org\netbeans\modules\form\layoutsupport\delegates. So open the folder C:\nb6_9_1\src\form as another project in your development-IDE(uncheck the checkbox “Open Required Projects:”). Expand Projects window node Form Editor > Source Packages > org.netbeans.modules.form.layoutsupport.delegates. Double click on AbsoluteLayoutSupport.java and set the breakpoint.

Inside Projects window, right click on your NBM and choose Debug from the context menu. That makes target-IDE (6.9.1) to launch. Choose Tools > Plugins from target-IDE main menu, then choose tab “Installed”. You should see your NBM inside the list of installed plugins. Nice, isn’t it?

Make some action that affects your NBM and enjoy debugging 🙂

Opening src\nbbuild as a project

Open your NBM project and set the breakpoint anywhere inside the code.

Open the following folder as a project: C:\nb6_9_1\src\nbbuild. The node “NetBeans Build System” appears inside Projects window.

Right-click the subnode build.xml and choose the following from context menu: Run Target > tryme-debug. That makes target-IDE (6.9.1) to launch. Choose Tools > Plugins from target-IDE main menu, then choose tab Downloaded. Press button “Add Plugins…”, find NBM on disk and then press button “Install”. Finish the installation process, then close Plugins window.

Make some action that affects your NBM and enjoy debugging 🙂

Optionally, you can set the breakpoint inside NB platform source code. Follow the same approach as given in “Adding target platform through NetBeans Platform Manager” step 6.