jar cfe test-1.0-fixed.jar com.test.Main -C target/classes .
Legends:
c = createf = filee = entry point (Main-Class)C = go into target/classes and pack everything insideSample:
java -jar test-1.0-fixed.jar
Add this to your pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archive>
<manifest>
<mainClass>com.test.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
After rebuilding, check it:
unzip -p target/test-1.0.jar META-INF/MANIFEST.MF
You should see:
Main-Class: com.test.Main