I have a project that contains a single module, and some dependencies. I\'d like to create a jar, in a separate directory, that contains the compiled module. In addition, I\
I was trying to build a jar from a multi-module Kotlin app and was getting the notorious 'no main manifest attribute' error. Creating the manifest directory in src/main/resources
didn't work either.
Instead, it works when creating it in src
directly: src/META-INF/MANIFEST.MF
.
It is probably little bit late, but I managed to solve it this way -> open with winrar and delete ECLIPSEF.RSA and ECLIPSEF.SF in META-INF folder, moreover put "Main-class: main_class_name" (without ".class") in MANIFEST.MF. Make sure that you pressed "Enter" twice after the last line, otherwise it won't work.
If you are working on spring/mvn project you can use this command:
mvn package -DskipTests
The jar file will be saved on target directoy.
My problem was this: I used Intellij IDEA (tried different versions) + Gradle. When I compiled the project and builded artifacf jar, as indicated in the above responses, I received an error - "no main manifest attrubute ..."
This solution worked for me (special thanks to Thilina Ashen Gamage (see above) for tip):
Excerpt - if you use external libraries and build a project through Project Settings - Artifacts - Add (+) - Jar - From modules with dependencies, then probably because of a program bug the META-INF folder with MANIFEST_MF file not including to jar. To avoid it create EMPTY jar file.
Project Settings - Artifacts - Add (+) - Jar - EMPTY JAR. META-INF folder will added to resources folder. Then select your main class. You will see following jar structure: Note the presence of a folder META-INF Then you can build your project and build artifacts. This solution worked for javaFX applications too.
For those that benefit from images as I do:
File -> Project Structure
With Maven you can use this plugin:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>[path you class main]</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>