title: Maven exec plugin ClassNotFoundException
body: <p>I'm using the Maven exec plugin to run a java application from the command line with the command mvn exec:java. I have specified the main class in the pom.xml and the associated dependencies.</p>
  
  <pre><code>&lt;groupId&gt;com.example.MyApp&lt;/groupId&gt;
  &lt;artifactId&gt;MyApp&lt;/artifactId&gt;
  &lt;version&gt;1.0.0&lt;/version&gt;
  &lt;build&gt;
    &lt;plugins&gt;
       &lt;plugin&gt;
         &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
         &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
         &lt;version&gt;1.2.1&lt;/version&gt;
         &lt;executions&gt;
           &lt;execution&gt;
             &lt;goals&gt;
               &lt;goal&gt;java&lt;/goal&gt;
            &lt;/goals&gt;
           &lt;/execution&gt;
         &lt;/executions&gt;
         &lt;configuration&gt;
            &lt;mainClass&gt;com.example.myclass&lt;/mainClass&gt;
            &lt;arguments&gt;
              &lt;argument&gt;configFile&lt;/argument&gt;
              &lt;argument&gt;properties&lt;/argument&gt;
            &lt;/arguments&gt;
         &lt;/configuration&gt;
       &lt;/plugin&gt;
  </code></pre>
  
  <p>I also specify a number of dependencies...</p>
  
  <pre><code>&lt;dependencies&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;log4j&lt;/groupId&gt;
      &lt;artifactId&gt;log4j&lt;/artifactId&gt;
      &lt;version&gt;1.2.17&lt;/version&gt;
      &lt;type&gt;jar&lt;/type&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.example.MyLibrary&lt;/groupId&gt;
      &lt;artifactId&gt;MyLibrary&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>The <code>MyApp</code> program reads a config file which is passed in as a command line argument. The config file contains the name of a class which is located in <code>MyLibrary</code>. So the class could be <code>com.mypackage.driver.MyClass</code> which is located in <code>MyLibrary</code> which is a dependency of the <code>MyApp</code> jar listed above. 
  However when I try to run this I get a <code>ClassNotFoundException</code>...</p>
  
  <p>Update----
  I'm using the system classloader to load the classes which are passed in on the command line for the <code>MyApp</code> program</p>
  
  <pre><code>ClassLoader loader = ClassLoader.getSystemClassLoader();
  </code></pre>
  
  <p>I'm thinking that this is causing the problem as it is looking for the classes on the default classpath which does not contain the dependencies. </p>
  
  <p>Any hints on what I'm doing wrong here?</p>