title: Java JAR unable to load class on Class-Path?
body: <p>I have a jar file that uses a class within a second jar file. However, when I run the first jar file, I get an exception that the class can not be found. I can't find any documentation on how to troubleshoot the issue.</p>
  
  <p>I have two .jar files, MyApp.jar and sqljdbc42.jar. Both of these .jar files are in the same directory.</p>
  
  <p>MyApp.jar has the following code in the main:</p>
  
  <pre><code>Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  </code></pre>
  
  <p>The manifest for MyApp.jar has the following:</p>
  
  <pre><code>Manifest-Version: 1.0
  Main-Class: com.mycompany.myapp.MyApp
  Class-Path: sqljdbc42.jar
  &lt;blank line&gt;
  </code></pre>
  
  <p>The class <code>com.microsoft.sqlserver.jdbc.SQLServerDriver</code> is in the jar sqljdbc42.jar.</p>
  
  <p>When MyApp.jar is executed, the following exception occurs:</p>
  
  <pre><code>java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
  </code></pre>
  
  <p>Using Java 8, built in IntelliJ, verified the manifest contents by opening the jar in 7Zip.
  Any advice on how I can get this (seemingly simple, basic piece of Java JAR concept) working would be greatly appreciated.</p>