I recently just started toying around with Maven in java. Time comes to test my project, it works fine in the NetBeans window, running the main class found in App.java (com.MyCompany.App), but when I try to run it from a command line I get an error:
java -jar fileName.jar
"No Main Manifest Attribute" in fileName.jar
I have tried adding a manifest.mf file specifying what main is, I've also been into project properties and added it as the main file...
What's going on?
I know this is an old question but in case it helps anyone.
You need the maven-jar-plugin (see Maven's example). This plugin will create the required entries in the manifest file when the project is built.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
You need the version, otherwise, project doesn't build. The fully.qualified.MainClass
starts at the package hierarchy.