title: How to include the lib folder in the manifest classpath in Netbeans
body: <p>A library that my java application uses needs looks for a file (log4j.xml) in the class path. I use netbeans to manage my project, but I can't find a way to include the lib/ folder.</p>
  
  <p>Netbeans automatically creates a MANIFEST.MF file inside the application jar and also creates a folder called lib/ which includes all dependencies. This manifest specifies a Class-Path attribute that overrides any -cp argument provided on the command line. I can select an arbitrary folder in netbeans' library panel, but it creates a sub folder in the manifest's classpath. I'd like all dependencies and the log4j.xml file inside the lib/ folder.</p>
  
  <p>Hopefully it's possible to do this in the IDE. I include a snippet of the auto-generated build-impl.xml file.</p>
  
  <pre><code>&lt;target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries"&gt;
      &lt;property location="${build.classes.dir}" name="build.classes.dir.resolved"/&gt;
      &lt;pathconvert property="run.classpath.without.build.classes.dir"&gt;
          &lt;path path="${run.classpath}"/&gt;
          &lt;map from="${build.classes.dir.resolved}" to=""/&gt;
      &lt;/pathconvert&gt;
      &lt;pathconvert pathsep=" " property="jar.classpath"&gt;
          &lt;path path="${run.classpath.without.build.classes.dir}"/&gt;
          &lt;chainedmapper&gt;
              &lt;flattenmapper/&gt;
              &lt;globmapper from="*" to="lib/*"/&gt;
          &lt;/chainedmapper&gt;
      &lt;/pathconvert&gt;
      &lt;taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/&gt;
      &lt;copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}"&gt;
          &lt;fileset dir="${build.classes.dir}"/&gt;
          &lt;manifest&gt;
              &lt;attribute name="Main-Class" value="${main.class}"/&gt;
              &lt;attribute name="Class-Path" value="${jar.classpath}"/&gt;
          &lt;/manifest&gt;
      &lt;/copylibs&gt;
      &lt;echo&gt;To run this application from the command line without Ant, try:&lt;/echo&gt;
      &lt;property location="${dist.jar}" name="dist.jar.resolved"/&gt;
      &lt;echo&gt;java -jar "${dist.jar.resolved}"&lt;/echo&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>Thanks.</p>