**Error :** Process 'command 'C:\Program Files\Java\jdk\bin\java.exe'' finished with non-zero exit value 1
This error is getting when i am running the task which is build.gradle file as follows,
plugins {
id 'application'
id 'eclipse'
}
// remove the Javadoc verification
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
// Build version
version = '1.2.6-SNAPSHOT'
sourceCompatibility = '1.8'
artifactory {
publish {
repository.repoKey = 'ent-public-local-builds'
}
}
eclipse.classpath {
containers = containers.collect {
it.replace 'org.eclipse.jdt.launching.JRE_CONTAINER',
'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/DeveloperJavaJDK'
}
}
//Core Spring version numbers
def springVersion = '5.1.9.RELEASE'
def springBatchVersion = '4.1.2.RELEASE'
//Junit version
def junitVersion = '5.5.1'
//updated to use Transitive Dependencies
dependencies {
// include Spring JARs and dependencies
implementation 'org.springframework:spring-oxm:' + springVersion
implementation 'org.springframework:spring-webmvc:' + springVersion
}
reporting.baseDir = "my-reports"
testResultsDirName = "$buildDir/my-test-results"
application {
mainClassName = 'com.automation.MyClass'
}
task runWithJavaExec(type: JavaExec) {
// group = 'Execution'
// description = "Run the main class with JavaExecTask"
classpath = sourceSets.main.runtimeClasspath
main = 'com.automation.MyClass'
}
runWithJavaExec.onlyIf { project.hasProperty('Execution')}
I ran this task by using below command,
gradle runWithJavaExec
Finally,I want to know how to run java class through gradle command ?Is there any possibility other than creation of a task? If yes please share accordingly. Please help me to solve this issue.
-s(with stack traces) or maybe even-is(set log to INFO level and with stack traces).runWithJavaExec.onlyIf { project.hasProperty('Execution')}means it should only run when you provide a property called Execution. Not sure why you have that in there, but maybe trygradle -is -PExecution runWithJavaExecand post the output leading up to and including the failure. As to why your application fails, that can really be anything. Maybe Spring can't find some required beans to autowire, maybe the runtime classpath is incomplete or similar.