title: Java ClassNotFound exception with Maven Dependency as a JAR
body: <p>I can't seem to solve this issue. Running <code>com.benmyers.Main</code> in IntelliJ with a Maven dependency works fine, and I receive no errors. When I use the Install tool in the Maven window to create an executable JAR file in the <code>target</code> directory, I receive the following error when attempting to run</p>
  <pre><code>java -jar &quot;C:\Users\...\target\AncientGreekTranslator-1.0-SNAPSHOT.jar&quot;
  </code></pre>
  <p>in Command Prompt:</p>
  <pre><code>Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: com/formdev/flatlaf/FlatDarculaLaf
          at com.benmyers.Main.main(Main.java:23)
  Caused by: java.lang.ClassNotFoundException: com.formdev.flatlaf.FlatDarculaLaf
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
          at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
          ... 1 more
  </code></pre>
  <p>I believe there is an issue with the Maven plugin in <code>pom.xml</code>:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
           xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;benlmyers.ancientGreekTranslator&lt;/groupId&gt;
      &lt;artifactId&gt;AncientGreekTranslator&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;archive&gt;
                          &lt;manifestFile&gt;src/main/resources/META-INF/MANIFEST.MF&lt;/manifestFile&gt;
                      &lt;/archive&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.formdev&lt;/groupId&gt;
              &lt;artifactId&gt;flatlaf&lt;/artifactId&gt;
              &lt;version&gt;0.43&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
          &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;/properties&gt;
  &lt;/project&gt;
  </code></pre>
  <p>I have tried the following:</p>
  <ol>
  <li><p>Adding <code>&lt;scope&gt;provided&lt;/scope&gt;</code> to the dependency in <code>pom.xml</code> (from <a href="https://stackoverflow.com/a/12811419/12101201">this answer</a>), which causes no visible change when running the JAR in Command Prompt, and</p>
  </li>
  <li><p>using <code>&lt;artifactId&gt;maven-plugins&lt;/artifactId&gt;</code> instead of <code>&lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;</code> among other <code>artifactId</code>s. Basically, I tried the answers from <a href="https://stackoverflow.com/questions/26014840/class-not-found-exception-for-a-maven-jar">this question</a> and <a href="https://stackoverflow.com/questions/15871065/classnotfoundexception-in-maven-project/16112614">this other question</a> but had no success.</p>
  </li>
  </ol>
  <p>I've received a comment requesting for my <code>Main.java</code>:</p>
  <pre class="lang-java prettyprint-override"><code>public class Main {
  
      private static GreekDictionaryInterpreter dictionaryInterpreter;
      private static Translator translator;
  
      private static MainForm mainForm;
  
      public static void main(String[] args) {
  
          dictionaryInterpreter = new GreekDictionaryInterpreter(new ArrayList&lt;Flag&gt;());
          translator = new GreekTranslator(dictionaryInterpreter.getDictionary(), new ArrayList&lt;Flag&gt;());
  
          FlatDarculaLaf.install(); // &lt;- Line that causes exception
  
          //LookAndFeelManager.setLookAndFeel();
  
          MainForm.main(dictionaryInterpreter, translator);
      }
  }
  
  </code></pre>
  <p>There are other answers for this, and I've searched through several and none of them have proven to be successful in my case. Any help would be greatly appreciated.</p>