15
**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.

5
  • 1
    There is likely more information about the problem in the output above the error you posted. If not, try running Gradle with -s (with stack traces) or maybe even -is (set log to INFO level and with stack traces). Commented Mar 12, 2020 at 9:52
  • When i ran using --stacktrace , now i am getting this Task :runWithJavaExec SKIPPED Skipping task ':runWithJavaExec' as task onlyIf is false. :runWithJavaExec (Thread[Daemon worker Thread 15,5,main]) completed. Took 0.0 secs. This task execution has been skipped . Commented Mar 12, 2020 at 10:10
  • Can anyone help me in how to run a task without skipping ? Commented Mar 12, 2020 at 10:27
  • @BjørnVester please share your thought on this issue Commented Mar 12, 2020 at 11:08
  • The line 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 try gradle -is -PExecution runWithJavaExec and 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. Commented Mar 13, 2020 at 9:19

11 Answers 11

25

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

Sign up to request clarification or add additional context in comments.

4 Comments

need specific steps to do this
This fixed my issue. Steps are pretty basic ... File -> invalidate cache.. -> invalidate and restart I was able to invalidate and restart the cache through this link jetbrains.com/help/idea/invalidate-caches.html
Helped thanks, normally you don't expect this from Intellij. Please fix this kind of bugs jetbrains team...
This Fixed my issue, just tap double shift on intelliJ and just type cache , you will get option of invalidateCache in list, select and choose option and done, thanks
7

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.

Comments

4

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

2 Comments

This answer is similar to another one. But you could enhance it by showing how to find the services that are using that port.
Would be great if you explain how to do 1 and 2
3

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

Comments

0

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

Comments

0

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

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

Comments

0

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

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

Comments

0

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...)

1 Comment

I hate when people say "sorry for my English"... especially after speaking perfect English.
0

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

1 Comment

This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review
0

For me I am using swagger2 with spring boot 2, Java 8, Gradle 2. I used below property in the application.properties. this works for me

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

Comments

0

There can be lot of reasons for this error to pop up while running the code in an IDE, In intellij if the active profile is not mentioned and there are internal dependencies and no default profile in application.yml. The application will fail to start right after the banner.

Need to make sure this small thing is not missed, profiles.active: or a default profile is always mentioned.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.