I am attempting to create a 0.0.1-SNAPSHOT.jar file that I can run via the, "java -jar 0.0.1-SNAPSHOT.jar" command.
I have a java/selenium/testng/maven project.
I have my pom.xml set up to include:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>mypackage.myclass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
The file myclass.java contains a main method.
I have various other packages and class files included on this project.
Even though I have specifed the mainClass attribute it's not being picked up. When I go to to run this jar file that is created I get the error:
$ java -jar 0.0.1-SNAPSHOT.jar
Error: Could not find or load main class mypackage.myclass
I have set the mainClass in the pom.xml as seen above.
When I pull the jar file apart with, "jar tf 0.0.1-SNAPSHOT.jar > output.txt" I notice that it's filled with nothing but dependencies. Absolutely none of my *.java files are anywhere. The jar does somehow contain a couple of sql files that I had attached to the resources directory however.
I have been scouring the internet for two days. Please can someone tell me what I'm doing wrong?