title: Building executable jar with maven?
body: <p>I am trying to generate an executable jar for a small home project called "logmanager" using maven, just like this:</p>
  
  <p><a href="https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven">How can I create an executable JAR with dependencies using Maven?</a></p>
  
  <p>I added the snippet shown there to the pom.xml, and ran mvn assembly:assembly. It generates two jar files in logmanager/target: logmanager-0.1.0.jar, and logmanager-0.1.0-jar-with-dependencies.jar. I get an error when I double-click on the first jar:</p>
  
  <pre><code>Could not find the main class: com.gorkwobble.logmanager.LogManager. Program will exit.
  </code></pre>
  
  <p>A slightly different error when I double-click the jar-with-dependencies.jar:</p>
  
  <pre><code>Failed to load Main-Class manifest attribute from: C:\EclipseProjects\logmanager\target\logmanager-0.1.0-jar-with-dependencies.jar
  </code></pre>
  
  <p>I copied and pasted the path and classname, and checked the spelling in the POM. My main class launches fine from an eclipse launch configuration. Can someone help me figure out why my jar file won't run? Also, why are there two jars to begin with? Let me know if you need more information.</p>
  
  <p>Here is the full <code>pom.xml</code>, for reference:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.gorkwobble&lt;/groupId&gt;
    &lt;artifactId&gt;logmanager&lt;/artifactId&gt;
    &lt;name&gt;LogManager&lt;/name&gt;
    &lt;version&gt;0.1.0&lt;/version&gt;
    &lt;description&gt;Systematically renames specified log files on a scheduled basis. Designed to help manage MUSHClient logging and prevent long, continuous log files.&lt;/description&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;version&gt;2.2&lt;/version&gt;
              &lt;!-- nothing here --&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.2-beta-4&lt;/version&gt;
              &lt;configuration&gt;
                &lt;descriptorRefs&gt;
                  &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                &lt;/descriptorRefs&gt;
                &lt;archive&gt;
                  &lt;manifest&gt;
                    &lt;mainClass&gt;com.gorkwobble.logmanager.LogManager&lt;/mainClass&gt;
                  &lt;/manifest&gt;
                &lt;/archive&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                &lt;execution&gt;
                  &lt;phase&gt;package&lt;/phase&gt;
                  &lt;goals&gt;
                    &lt;goal&gt;single&lt;/goal&gt;
                  &lt;/goals&gt;
                &lt;/execution&gt;
              &lt;/executions&gt;
            &lt;/plugin&gt;
            &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                &lt;source&gt;1.6&lt;/source&gt;
                &lt;target&gt;1.6&lt;/target&gt;
              &lt;/configuration&gt;
            &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
    &lt;dependencies&gt;
      &lt;!-- commons-lang --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-lang&lt;/groupId&gt;
          &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
          &lt;version&gt;2.4&lt;/version&gt;
      &lt;/dependency&gt; 
  
      &lt;!-- Quartz scheduler --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;opensymphony&lt;/groupId&gt;
          &lt;artifactId&gt;quartz&lt;/artifactId&gt;
          &lt;version&gt;1.6.3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- Quartz 1.6.0 depends on commons collections --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;commons-collections&lt;/groupId&gt;
        &lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
        &lt;version&gt;3.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- Quartz 1.6.0 depends on commons logging --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;commons-logging&lt;/groupId&gt;
        &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
        &lt;version&gt;1.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- Quartz 1.6.0 requires JTA in non J2EE environments --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;javax.transaction&lt;/groupId&gt;
        &lt;artifactId&gt;jta&lt;/artifactId&gt;
        &lt;version&gt;1.1&lt;/version&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- junitx test assertions --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit-addons&lt;/groupId&gt;
          &lt;artifactId&gt;junit-addons&lt;/artifactId&gt;
          &lt;version&gt;1.4&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- junit dependency; FIXME: make this a separate POM --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;4.1&lt;/version&gt;
      &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
    &lt;dependencyManagement&gt;
    &lt;/dependencyManagement&gt;
  &lt;/project&gt;
  </code></pre>