title: NoClassDefFoundError when jar file in created in a subdirectory
body: <p>When I create a jar file in a subdirectory, the <code>BouncyCastleProvider</code> class from <a href="https://www.bouncycastle.org/download/bcprov-jdk15on-159.jar" rel="nofollow noreferrer">bcprov-jdk15on-159.jar</a> fails to load with a <code>ClassNotFoundException</code>. I would think that the location where a jar file is created should have no impact on its contents and behavior.</p>
  
  <p>Here is the example of creating a working jar.</p>
  
  <pre><code>$ jar cfm MyProject.jar Manifest.txt Main.class bcprov-jdk15on-159.jar
  $ java -jar MyProject.jar
  hello provider: BC version 1.59
  </code></pre>
  
  <p>And here is the example where running jar with exactly the same input files, but a different jar file destination, results in a failing jar.</p>
  
  <pre><code>$ jar cfm dist/MyProject.jar Manifest.txt Main.class bcprov-jdk15on-159.jar
  $ java -jar dist/MyProject.jar
  Error: Unable to initialize main class Main
  Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider
  </code></pre>
  
  <p>This is the file <code>Manifest.txt</code></p>
  
  <pre><code>Manifest-Version: 1.0
  Main-Class: Main
  Class-Path: bcprov-jdk15on-159.jar
  </code></pre>
  
  <p>and this is the <code>Main.java</code> file that uses the <code>BouncyCastleProvider</code> class.</p>
  
  <pre><code>public class Main {
      public static void main(String... arg) {
          java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
          java.security.Provider p = java.security.Security.getProvider("BC");
          System.out.println("hello provider: " + p);
      }
  }
  </code></pre>
  
  <p>I see this behavior both with JDK 8 and with JDK 9, and also both with the JDK jar command (shown above) and with Ant's jar task.</p>
  
  <p>I stumbled on this problem while trying to upgrade the <a href="http://sourceforge.net/projects/pcsecrets/files/?source=navbar" rel="nofollow noreferrer">PCSecrets</a> password manager to work under Java 9.</p>