I'm trying to build a maven java program on on Windows7 and my java -version is 1.7. I'm getting this error:
"Error: Could not find or load main class com.mycompany.App" when trying to execute Maven-generated Jar
even though com/mycompany/App.class
exists within the Jar and it has a main method. Here is what my META-INF/MANIFEST.MF
looks like:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: me
Build-Jdk: 1.7.0_03
Main-Class: com.mycompany.App
Class-Path: C:/Users/me/.m2/repository/com/mycompany/commons/2.1-SNAPSHOT/commons-2.1-SNAPSHOT.jar
I'm trying to execute the jar using:
java -jar mycompany-2.1-SNAPSHOT.jar 12:141678 1
There is a blank line at the end of my Manifest file. I'm using Maven 3.0.5 and using mvn package to generate the jar file. Here is a portion of my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathLayoutType>repository</classpathLayoutType>
<classpathPrefix>${settings.localRepository}</classpathPrefix>
<mainClass>com.mycompany.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
Can someone help me understand what is causing this error?