Maven adding mainClass in pom.xml with the right folder path
First, your main class doesn't include src/main/java
. Look at the package declaration in that Java file. For example, package org.jis;
, then add the main class to that. In other words, it's only org.jis.Main
.
You need to configure the maven-jar-plugin instead the of the maven-compiler-plugin. The jar-plugin is the one which is responsible for packaging and creating the manifest.MF.
From http://maven.apache.org/shared/maven-archiver/examples/classpath.html
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
...
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
</configuration>
...
</plugin>
</plugins>
</build>
You may mention as below if it's a spring boot application.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.test.MainClass</mainClass>
</configuration>
</plugin>
</plugins>
</build>