Gradle - Could not find or load main class
Solution 1:
I see two problems here, one with sourceSet
another with mainClassName
.
-
Either move java source files to
src/main/java
instead of justsrc
. Or setsourceSet
properly by adding the following to build.gradle.sourceSets.main.java.srcDirs = ['src']
-
mainClassName
should be fully qualified class name, not path.mainClassName = "hello.HelloWorld"
Solution 2:
Modify build.gradle to put your main class in the manifest:
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart',
'Implementation-Version': version,
'Main-Class': 'hello.helloWorld'
}
}