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

190
Views
Gradle Output Jar has no Main-Class

I have the following simple build.gradle file:

apply plugin: 'application'
apply plugin: 'java'

mainClassName = 'com.kurtis.HelloGradle'

And the following single java file located at src/main/java/com/kurtis/HelloGradle.java:

package com.kurtis;

public class HelloGradle {

    public static void main(String[] args) {

        System.out.println("Hello gradle");
    }

}

However, if I run gradle build I get a jar in the build/lib directory that has no main class set. It's manifest file has no Main-Class entry. Why is this?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's due to the way application plugin works. mainClassName is a property used by application plugin, when it creates an executable jar, it doesn't need to have a Main-Class in the manifest, since it doesn't use it.

If you need to have a Main-Class in your jar, then you have to provide it vie jar configuration of the java plugin as follows:

jar {
  manifest {
    attributes(
      'Main-Class': 'com.kurtis.HelloGradle'
    )
  }
}

Otherwise, just use an executable, which is generated by application plugin, whether via run task or via distributions it can create for you, with scripts to run your application and all it's dependencies.

about 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!