intellij-ideakotlinjvmmanifestmanifest.mf

"No main manifest attribute" when creating Kotlin jar using IntelliJ IDEA


When creating a jar from my Kotlin code and running it, it says "No main manifest attribute". When looking at the manifest.mf, it has this content:

Manifest-Version: 1.0

When looking at the file in the source, it has this content:

Manifest-Version: 1.0
Main-Class: MyMainClass

When manually copying the source manifest to the jar, it runs perfectly.

Screenshot of my artifact settings


Solution

  • If any of the dependent jars has a MANIFEST.MF file, it will override your custom one which defines the Main-Class.

    In order to address this problem you should do the following:

    See the related issue for more details.

    You can also use Gradle or Maven to generate the fat jar instead.