title: How can a runnable jar load external xml file at runtime?
body: <p>(This seems like a trivial enough problem, but stuck for 2 days :( )</p>
  
  <p>I have a runnable jar (created with <code>maven assembly plugin</code>). A class inside the jar looks for an xml file on classpath. However, we do not want to bundle the xml file in the jar and want it to be externalized.</p>
  
  <p>Tried till now:</p>
  
  <ol>
  <li><p>Set the classpath at runtime:</p>
  
  <pre><code>java -classpath ./conf -jar my-jar-with-dependencies.jar
  </code></pre></li>
  </ol>
  
  <p>==> doesn't load (conf folder contains the xml)</p>
  
  <ol start="2">
  <li><p>Set classpath in assembler plugin</p>
  
  <pre><code>        &lt;plugin&gt;
          &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
          &lt;executions&gt;
              &lt;execution&gt;
                  &lt;id&gt;make-assembly&lt;/id&gt;
                  &lt;phase&gt;package&lt;/phase&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;single&lt;/goal&gt;
                  &lt;/goals&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;
          &lt;configuration&gt;
              &lt;archive&gt;
                  &lt;manifest&gt;
                      &lt;mainClass&gt;com.xxx.Test&lt;/mainClass&gt;
                      &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                      &lt;classpathPrefix&gt;./conf/&lt;/classpathPrefix&gt;
                  &lt;/manifest&gt;
              &lt;/archive&gt;
              &lt;descriptorRefs&gt;
                  &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
              &lt;/descriptorRefs&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt;
  </code></pre></li>
  </ol>
  
  <p>==> does not add ClassPath to MANIFEST.MF in the runnable jar</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Generated <code>MAINFEST.MF</code> in the jar:</p>
  
  <pre><code>Manifest-Version: 1.0
  Archiver-Version: Plexus Archiver
  Created-By: Apache Maven
  Built-By: xxx
  Build-Jdk: 1.7.0_21
  Main-Class: com.xxx.Test
  </code></pre>
  
  <p><strong>Edit 2</strong>:</p>
  
  <p>So I edited the generated <code>MANIFEST</code> in the jar and recreated jar. Still doesn't find the xml!</p>
  
  <pre><code>Manifest-Version: 1.0
  Archiver-Version: Plexus Archiver
  Created-By: Apache Maven
  Built-By: xxx
  Build-Jdk: 1.7.0_21
  Main-Class: com.xxx.Test
  Class-Path: . /* Tried with both . and ./conf */
  </code></pre>