NetBeans Modules for Dummies (Part 4)

I made some progress with the Ant scripts that I use to create my NBMs. In the first part of this "NetBeans Modules for Dummies" pseudo-series, I mentioned several workarounds for problems that are caused, as it turns out, when the wrong version of nbantext.jar is used. In the openide-dev mailing list, which I only discovered today, Jesse Glick says the following in response to someone else querying the use of nbantext.jar: "The version in the release41 branch assumes the existence of the nb.system.dir property, which is defined in in that branch. The trunk version does not use this property (and the properties file is gone)." Somehow I haven't been able to find the version that I should be using. So, instead, I've had to use the structure that my version (downloaded from the Update Center) demands. This structure happens to be identical to that used by Elan Meng and so I am greatful for having found his blog (and, of course, greatful to him for having written it). So, the solution to using the "faulty" version of nbantext.jar is as follows (assuming that your module is called ColorSwitcher):
  1. Define the following in

  2. Add the following two scripts to your build.xml file:

    <target name="create-xml-file-for-module" depends="compile,jar" description="Create XML File.">
      <!-- Create directory for JAR. -->
      <mkdir dir="netbeans/${modules.dir}"/>
      <!-- Create directory for JAR's XML file. -->
      <mkdir dir="netbeans/${modulexml.dir}"/>
      <!-- Copy the JAR (therefore, you must build the JAR first!). -->
      <copy file="${dist.jar}"
      <!-- Create the XML for the JAR (therefore, must have an appropriate first!). -->
      <taskdef name="createmodulexml" 
           classpath="${javac.classpath}" />
      <createmodulexml xmldir="netbeans/${modulexml.dir}">
        <enabled dir="netbeans/${cluster.dir}">
          <include name="modules/${}.jar"/>

    <target name="create-nbm" depends="create-xml-file-for-module" description="Create NBM File.">
    <taskdef name="genlist" classpath="${javac.classpath}" 
    <genlist outputfiledir="netbeans/${cluster.dir}" module="modules/${}.jar">
    <fileset dir="netbeans/${cluster.dir}">
    	<include name="modules/${}.jar"/>
    	<include name="config/Modules/${}.xml"/>
    <taskdef name="makenbm" classpath="${javac.classpath}" classname="org.netbeans.nbbuild.MakeNBM"/>
    <makenbm file="${}.nbm" 

The above targets assume that you've added the related JARs to the javac.classpath property. Do this by right-clicking the project's Libraries node and adding the nbantext.jar, openide.jar, and openide-loaders.jar. This is the result when I run the two scripts:

Finally, I know that there's something called "cluster harness" available for building NBMs, but I'd rather do it myself with my own Ant script. Bunches of extra files, unless necessary, make things even more complex than they already are.


I want to add button action in the toolbar under the menue with some should i proceed.waiting for your reply...

Posted by Abhisek on September 27, 2007 at 02:58 PM PDT #

Posted by Geertjan on September 27, 2007 at 06:00 PM PDT #

I have created multiple modules and place them in a module suite. Everything is fine until I run the project. It seems that my modules cannot see classes from other modules that are in the same suite. I have spent 3 days on this, trying different configurations and still nothing workd. I get a "ClassNotFoundException" but when i looked at the modules\\ext\\jar files - the class is there.
Could you help me?

Posted by Mary on December 20, 2007 at 08:40 AM PST #

Hi Mary, why not take a tutorial, you'll learn a lot:

Also, join the mailing list:

Posted by Geertjan on December 20, 2007 at 01:18 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