Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

627
Views
"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

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

I got this error with Gradle and Kotlin. I had to add in my build.gradle.kts an explicit manifest attribute:

tasks.withType<Jar> {
    manifest {
        attributes["Main-Class"] = "com.example.MainKt"
    }
}

From the gradle documentation, it's better to create a fatJar task to englobe all of the runtime dependencies in case you encounter java.lang.NoClassDefFoundError errors

over 4 years ago · Santiago Trujillo Report

0

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:

  • Disable the alphabetical ordering
  • Change items ordering so that item which has META-INF/MANIFEST.MF file is the first in the list
  • Your custom MANIFEST.MF will be picked up by IntelliJ IDEA and displayed for the jar artifact.

See the related issue for more details.

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

over 4 years ago · Santiago Trujillo Report

0

1.Add the following task definition in the build script

tasks.jar {
manifest {
    attributes["Main-Class"] = "MainKt"
}
configurations["compileClasspath"].forEach { file: File ->
    from(zipTree(file.absoluteFile))
}
}
  1. Then the jar tasks (Tasks | build | jar) again from the right hand sidebar.
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!