Producing executable jar in NetBeans

Solution 1:

I just had the same problem in NetBeans 7.2.1 with a Maven Java Application project. Modify the pom.xml file to include the maven assembly plugin with one tweak to myrho's answer (needs to reference the predefined descriptor "jar-with-dependencies"):

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <archive>
            <manifest>
                <mainClass>your.app.MainClass</mainClass>
            </manifest>
        </archive>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

An alternate method is to build a Java Application project in NetBeans that doesn't use Maven. Select File -> Project Properties -> Build -> Packaging and check the "Copy Dependent Libraries" checkbox.

Solution 2:

Try this:

  1. Right click your project on the "Projects" panel, select "Properties"

  2. Click on "Run" in the new window.

  3. Edit the "Main Class:" field (click on Browse).

This way you will select the main class which is the entry point to your application and the Manifest will be created correctly.

Solution 3:

If you are using the maven assembly plugin and want to build an executable jar with dependencies, you need to add this portion to the configuration of the maven-assembly-plugin section in your pom.xml:

<plugin>
  <artifactId>maven-assembly-plugin</artifactId>
  <configuration>
    <!-- ... -->
    <archive>
      <manifest>
        <mainClass>your.app.SampleClass</mainClass>
      </manifest>
    </archive>
  </configuration>
</plugin>

Source: Maven Assembly Plugin Usage

Solution 4:

Very simple, The .jar and .jad files are there in dist folder

I was also searching for answer and got this one from http://forums.netbeans.org/ptopic3465.html

Solved :)

Solution 5:

Did you clean the project and rebuild? It sound like you're doing it right. Heres some references just in case:

http://www.velocityreviews.com/forums/t141385-how-to-create-executable-jar-in-netbeans-ide.html http://dr.berkeley.edu/REM/wiki/index.php/Making_a_Java_executable_jar_in_Netbeans