No main manifest attribute

plugins

(Thufir) #1

How do I set the main class?

thufir@doge:~/NetBeansProjects/Firebase$ 
thufir@doge:~/NetBeansProjects/Firebase$ ./gradlew build --scan

BUILD SUCCESSFUL in 10s
2 actionable tasks: 2 executed

Publishing build scan...
https://gradle.com/s/gwb6wfhdghyfi

thufir@doge:~/NetBeansProjects/Firebase$ 
thufir@doge:~/NetBeansProjects/Firebase$ java -jar build/libs/Firebase.jar 
no main manifest attribute, in build/libs/Firebase.jar
thufir@doge:~/NetBeansProjects/Firebase$ 
thufir@doge:~/NetBeansProjects/Firebase$ cat build.gradle
plugins {
    id 'com.gradle.build-scan' version '1.8' 
    id 'java'
}

buildScan {
    licenseAgreementUrl = 'https://gradle.com/terms-of-service'
    licenseAgree = 'yes'
}

repositories {
    jcenter()
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.24'

    testCompile 'junit:junit:4.12'
}
thufir@doge:~/NetBeansProjects/Firebase$ 

Gradle has changed a bit. To get latest had to find SDKMAN! and then spent a bit of time figuring out how to use gradle init to create the wrapper so that it plays nicely with Netbeans. Hence, admittedly, wasn’t able to research how to set the main class correctly; pardon.


(James Justinic) #2

You need to specify the Main-Class in the manifest of the jar file. Replace com.example.Main with your actual fully qualified class name:

jar {
    manifest {
        attributes 'Main-Class': 'com.example.Main'
    }
}