Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda