The start up script generated by Gradle can't find the main class when I run it:
./ApplicationName.bat
Error: Could not find or load main class packageName.NameOfMainClass
My build.gradle file looks something like this:
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/6.8.2/userguide/building_java_projects.html
*/
plugins {
// Create jar file
id 'java'
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}
repositories {
// Use JCenter for resolving dependencies.
jcenter()
// Maven
mavenCentral()
}
def jmockitVersion = '1.49'
dependencies {
// JMockit
testImplementation "org.jmockit:jmockit:$jmockitVersion"
// Use JUnit test framework.
testImplementation 'junit:junit:4.13'
// This dependency is used by the application.
implementation 'com.google.guava:guava:29.0-jre'
//other dependencies not shown
.
.
.
}
test {
jvmArgs "-javaagent:${classpath.find { it.name.contains("jmockit") }.absolutePath}"
}
application {
// Define the main class for the application.
mainClass = 'packageName.NameOfMainClass'
}
jar {
archivesBaseName = 'ApplicationName'
archiveVersion = '0.0.1-SNAPSHOT'
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart',
'Implementation-Version': version,
'Main-Class': 'packageName.NameOfMainClass'
}
}
run {
standardInput(System.in)
}
The generated jar's MANIFEST.MF looks like this:
Manifest-Version: 1.0
Implementation-Title: Gradle Quickstart
Implementation-Version: 0.0.1-SNAPSHOT
Main-Class: packageName.NameOfMainClass
The file structure is something like this:
applicationName\
gradlew
gradlew.bat
settings.gradle
README.md
.gradle\
gradle\
applicationName\
build.gradle
build\
src\
main\
java\
packageName\
NameOfMainClass.java
OtherClass.java
.
.
.
resources\
test\
java\
packageName\
SomeTest.java
.
.
.
resources\
I'm new to Gradle. I've tried a number things in other posts, that may or may not be similar, but with no success.