Note that there are some explanatory texts on larger screens.

plurals
  1. POExecutable Jar: java.lang.ClassNotFoundException sometimes fires when running
    text
    copied!<p>I have an executable jar created using Maven, using the assembly plugin like so:</p> <pre><code> &lt;plugin&gt; &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;archive&gt; &lt;manifest&gt; &lt;mainClass&gt;org.htmlcleaner.GUI&lt;/mainClass&gt; &lt;/manifest&gt; &lt;/archive&gt; &lt;descriptorRefs&gt; &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt; &lt;/descriptorRefs&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;make-assembly&lt;/id&gt; &lt;!-- this is used for inheritance merges --&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;!-- bind to the packaging phase --&gt; &lt;goals&gt; &lt;goal&gt;single&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>The actual Main method looks like this:</p> <pre><code>public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { new GUI(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); } </code></pre> <p>When I package my application, I get a jar-with-dependencies.jar, which I can run by double-clicking it.</p> <p>However, if I then quit or close the application, and then try to run it again, I sometimes see a ClassNotFoundException in the logs, and the application doesn't launch. (The Exception relates to one of the classes it depends on in the jar. Its definitely there.)</p> <p>This happens fairly frequently, but not every time. It seems to be any time I try to re-run the application within about 10 seconds of closing it.</p> <p>Is this just a "one of those things" you get when using Java for desktop apps?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload