NetBeans – include external libraries

Put something like this at the bottom of build.xml, just before “</project>”:

<target name="-post-jar">
  <jar jarfile="${dist.jar}" update="true">
    <zipfileset src="${dist.jar}" includes="**/*.class" />
    <zipfileset src="${reference.mylib.jar}" includes="**/*.class"/>

You have to change reference.mylib.jar above to match the name of your library. If you have added your libraries to the project with the “Add Project” button in the “Libraries” section of the “Project Properties” dialog, your file will contain lines like the following for each included library project:


The part before “=” is the string you should use in the src attribute of the zipfileset element.

If you have more than one library, add a zipfileset element for each of them.