Process 'command 'C:\Program Files\Java\jdk\bin\java.exe'' finished with non-zero exit value 1 eclipse

Viewed 56809
**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.

9 Answers

If you are using the intellij just invalidate the caches and restart

This happen usually when you define a property file or some file in the code, But when application running it try to get the file but it cannot locate file in the project. You should move the files to resource folder.

Change the port number on which you're running your springboot application. It worked for me.

Error : Process 'command 'C:\Program Files\Java\jdk\bin\java.exe'' finished with non-zero exit value 1...

This error is showing because some other service is running on the same port as the one you are running on your application. For example your application maybe trying to run on port 8080 but some other application is also running on port 8080. To solve this you can

  1. stop all services running on the port for example stop services that are running on port 8080 or
  2. you can just change the application port in the applications.properties to a new port for example change the port your application is running on from 8080 to 8081

This happens when you have DB plugins in your project but you did not specify DB details in application.property file.

If using Ktor, check that the Netty engine has the correct class in the build.gradle:

application {
    mainClass = 'com.octagon_technologies.songa.server.ApplicationKt'
}

1 - in your terminal run: java --version terminal image

2 - change in build.gradle the param sourceCompatibility for your actual java version. gradle image

i found one way to solucionate this error.

I changed the port where my application run (default is 8080)

In the resources foulder there is a file called application.properties.

you need this line of code: server.port = 8888

I guess this way can helps you...

(Sorry for my english, i'm learning...)

I have encountered a similar problem because there is no corresponding .class file in the build directory

Related