title: Help with setting up classpath in an executable jar file
body: <p>I am trying to build an executable jar with maven-assembly-plugin with all the dependencies. I want the dependencies in a /lib/ directory inside the jar, with the main jar outside, and the configuration files in the same level of the main jar.</p>
  
  <p>My pom.xml is:</p>
  
  <pre><code>&lt;plugin&gt;
                  &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.2.1&lt;/version&gt;
                  &lt;configuration&gt;
                    &lt;archive&gt;
                      &lt;manifest&gt;
                        &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                        &lt;classpathPrefix&gt;lib/&lt;/classpathPrefix&gt;
                        &lt;mainClass&gt;org.main.Class&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                      &lt;manifestEntries&gt;
                          &lt;Class-Path&gt;/ MainClass.jar&lt;/Class-Path&gt;
                      &lt;/manifestEntries&gt;
                    &lt;/archive&gt;
                    &lt;descriptors&gt;
                       &lt;!--Relative path to your descriptor --&gt;
                       &lt;descriptor&gt;src/main/assembly/packagejar.xml&lt;/descriptor&gt;
  
                    &lt;/descriptors&gt;
                  &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>The packagejar.xml is:</p>
  
  <pre><code>&lt;id&gt;eval&lt;/id&gt;
    &lt;formats&gt;
      &lt;format&gt;jar&lt;/format&gt;
    &lt;/formats&gt;
    &lt;includeBaseDirectory&gt;false&lt;/includeBaseDirectory&gt;
    &lt;fileSets&gt;
      &lt;fileSet&gt;
        &lt;directory&gt;${project.build.directory}&lt;/directory&gt;
        &lt;outputDirectory&gt;/&lt;/outputDirectory&gt;
        &lt;includes&gt;
          &lt;include&gt;MainClass.jar&lt;/include&gt;
        &lt;/includes&gt;
      &lt;/fileSet&gt;
    &lt;/fileSets&gt;
    &lt;files&gt;
      &lt;file&gt;
          &lt;source&gt;/src/main/resource/logging.properties&lt;/source&gt;
          &lt;outputDirectory&gt;/&lt;/outputDirectory&gt;
      &lt;/file&gt;
      &lt;file&gt;
          &lt;source&gt;/src/main/resource/log4j.properties&lt;/source&gt;
          &lt;outputDirectory&gt;/&lt;/outputDirectory&gt;
      &lt;/file&gt;
      &lt;file&gt;
          &lt;source&gt;/src/main/resource/hibernate.cfg.xml&lt;/source&gt;
          &lt;outputDirectory&gt;/&lt;/outputDirectory&gt;
      &lt;/file&gt;
    &lt;/files&gt;
    &lt;dependencySets&gt;
      &lt;dependencySet&gt;
        &lt;outputDirectory&gt;/lib/&lt;/outputDirectory&gt;
        &lt;useProjectArtifact&gt;false&lt;/useProjectArtifact&gt;
        &lt;unpack&gt;false&lt;/unpack&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependencySet&gt;
    &lt;/dependencySets&gt;
    &lt;/assembly&gt;
  </code></pre>
  
  <p>And the resulting manifest.mf file is:</p>
  
  <pre><code>Manifest-Version: 1.0
  Archiver-Version: Plexus Archiver
  Created-By: Apache Maven
  Built-By: German
  Build-Jdk: 1.6.0_22
  Main-Class: org.main.Class
  Class-Path: / MainClass.jar lib/dependency1.jar lib/dependency2.jar etc...
  </code></pre>
  
  <p>With this, I get the mainclass to execute, but it never finds the jars inside lib it needs to work. Probably I'm missing something basic. I've tried also adding in the pom.xml manifestEntries a lib/<em>, lib/</em>.jar, /lib and /lib/. </p>
  
  <p>Any ideas?</p>
  
  <p>Thanks in advance.</p>