Geertjan's Blog

  • May 9, 2005

NetBeans Modules for Dummies (Part 4)

Geertjan Wielenga
Product Manager
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 directories.properties 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 project.properties:

  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 manifest.mf first!). -->
    <taskdef name="createmodulexml"
    classpath="${javac.classpath}" />
    <createmodulexml xmldir="netbeans/${modulexml.dir}">
    <enabled dir="netbeans/${cluster.dir}">
    <include name="modules/${module.name}.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/${module.name}.jar">
    <fileset dir="netbeans/${cluster.dir}">

    <include name="modules/${module.name}.jar"/>

    <include name="config/Modules/${module.name}.xml"/>
    <taskdef name="makenbm" classpath="${javac.classpath}" classname="org.netbeans.nbbuild.MakeNBM"/>
    <makenbm file="${module.name}.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.

Join the discussion

Comments ( 4 )
  • Abhisek Thursday, September 27, 2007

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

  • Geertjan Friday, September 28, 2007
  • Mary Thursday, December 20, 2007

    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?

  • Geertjan Thursday, December 20, 2007

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


    Also, join the mailing list:


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.