0

I know there many versions of this question is all over the place. However, I went through most of them and it did not work for me.

I followed this link https://netbeans.org/kb/docs/java/javase-deploy.html to package my java source but the folders build and dist are not added to the project folder as it's stated in the official article. The folder I see after building the application are

  • classes
  • maven-archiver
  • surefire
  • surefire-report
  • test-classes
  • myApp.jar file

Additionally, I set the main class to the main class of my Application in the Netbeans by choosing properties->run->Main Class.

Now, the problem is that the jar file is not executed and gives me the "no main manifest attribute" error. Also, I tried to add some of the suggested tags in the pom.xml but that gave me errors as well. How could I fix this?

my pom.xml file:

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.mycompany</groupId>
<artifactId>TerminalGUI</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>TerminalGUI</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.googlecode.lanterna</groupId>
            <artifactId>lanterna</artifactId>
            <version>2.1.6</version>
        </dependency>
    </dependencies>

Thanks,

jax
  • 840
  • 2
  • 17
  • 35
  • possible duplicate of [How can I create an executable jar with dependencies using Maven?](http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven) – Boris the Spider Dec 20 '13 at 17:06
  • I followed the above recommendation but as I stated it gave me the error to fix the pom. – jax Dec 20 '13 at 17:15
  • This is the correct approach. If you do not tell us the error we cannot help you. Please edit your question to include the **exact** pom fragment you tried and the **exact** error you got. – Boris the Spider Dec 20 '13 at 17:16
  • @BoristheSpider: First I do not know why Netbeans did not create the mf file!Secondly I added the content of my pom.xml above. How should I add the suggested tags and where? It is possible that I did it wrong. – jax Dec 20 '13 at 17:25
  • The tags should go in their entirety somewhere in your pom - after dependencies is fine. You should then change the main class to the correct one. You will then have two jars in target; one of them will have the "with-dependencies" qualifier. This is the one you need to run. If you read the answer you will see that you need to use the second fragment if you want this to happen automatically. – Boris the Spider Dec 20 '13 at 17:48

0 Answers0