My answer is 10 years later but in case like that, you need to use a more precise model for the maven shade plugin. Use this form of this plugin:
<build>
<plugins>
<plugin>
<!-- Create a FAT JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>flag.yourCompany.yourMainClass</mainClass>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName />
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Now, If you have an IDE like JetBrains IntelliJ IDEA, put this command on it for the maven configuration:
clean compile verify
If you want to perform a command in the folder of your project that contains pom.xml, you can just do it:
mvn verify
Now to check if your jar has a manifest, copy-paste the shaded version Name-1.0-SNAPSHOT-shaded.jar
in a file named Name.zip
(note that you must change the extension) and go to META-INF
folder. You can finally see a MANIFEST.MF
file in the list of files. Extract it and see the content, it must be like that:
Manifest-Version: 1.0
Created-By: Maven JAR Plugin 3.4.1
Build-Jdk-Spec: 24
Main-Class: flag.yourCompany.yourMainClass
The command (replace with your yourMainClass-yourVersion-shaded.jar
):
java -jar Name-1.0-SNAPSHOT-shaded.jar
now works in the terminal if you have correctly configurated your JAVA_HOME environment variable! (but I don't know if it is executable directly by Windows cause I have differents versions of Java in my PATH)