title: Application runs fine in Intellij but doesn't work when packaged into an exe file
body: <p>I have built a very simple command line application using <a href="https://picocli.info" rel="nofollow noreferrer">picocli</a> and I would like to package it into an executable file. I first packaged it into a <code>jar</code> file using Maven package, and then used <a href="https://sourceforge.net/projects/launch4j/" rel="nofollow noreferrer">Launch4J</a> as recommended by several users on SO to  obtain an executable. However, it throws the NoClassDefFound error, when I run <code>Application.exe</code> in the command prompt.</p>
  <pre><code>&gt; Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError:
  &gt; picocli/CommandLine                                                 
  &gt; at mycli.HelloCli.main(HelloCli.java:48)                              
  &gt; Caused by: java.lang.ClassNotFoundException: picocli.CommandLine      
  &gt; at java.net.URLClassLoader.findClass(Unknown Source)                  
  &gt; at java.lang.ClassLoader.loadClass(Unknown Source)                    
  &gt; at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)         
  &gt; at java.lang.ClassLoader.loadClass(Unknown Source)                    
  &gt; ... 1 more
  </code></pre>
  <p>The application works perfectly well when executed in IntelliJ. I tried adding the custom jar file I created by looking at answers similar to <a href="https://stackoverflow.com/questions/1082580/how-to-build-jars-from-intellij-properly">these</a> but it doesn't seem to help. I also tried changing the folder of execution but that doesn't solve the error either.</p>