2

I am trying to use gradle to run a local server on my windows machine. I have java version 12 on my local machine

when i run java -version

 java -version
java version "12" 2019-03-19
Java(TM) SE Runtime Environment (build 12+33)
Java HotSpot(TM) 64-Bit Server VM (build 12+33, mixed mode, sharing)

I am trying to run gradle to see what version of gradle i am running and this is what i get.

 gradle bootRun --stacktrace

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '12'.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
java.lang.IllegalArgumentException: Could not determine java version from '12'.
        at org.gradle.api.JavaVersion.toVersion(JavaVersion.java:63)
        at org.gradle.api.JavaVersion.current(JavaVersion.java:72)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:32)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gra

dle.launcher.GradleMain.main(GradleMain.java:23)

I am not sure how to fix it. I also added everything to the correct environment variables

enter image description here

enter image description here

Omar_Jandali
  • 485
  • 2
  • 7
  • 18
  • not sure what the build.gradle is? @dimwittedanimal – Omar_Jandali Apr 03 '19 at 18:19
  • 2
    Seems you are using a really old Gradle version (2.8). Gradle added support for JDK 11 in Gradle version 5.0. Not sure if JDK 12 is supported at all yet, the version is too fresh. – tryman Apr 03 '19 at 18:29
  • I ran build.gradle and I got this `A problem occurred evaluating root project 'owf-framework'. > Cannot add task 'wrapper' as a task with that name already exists.` @tryman – Omar_Jandali Apr 03 '19 at 18:39
  • I also got this error when i did build.gradle `What went wrong: A problem occurred evaluating project ':owf-example-widgets'. > Failed to apply plugin [id 'org.grails.grails-plugin'] > Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput. ` @tryman – Omar_Jandali Apr 03 '19 at 18:44
  • I am now running java 11 and gradle 5.3.1. i ran build.gradle again and it is till throwing errors... @tryman – Omar_Jandali Apr 03 '19 at 18:51
  • 1
    build.gradle is a script used by Gradle (not the user) to build the project. So those are not actual errors, you just tried running something that should be run by Gradle instead. Check the Gradle guide on how the system works. – tryman Apr 03 '19 at 18:53
  • 1
    Possible duplicate of [Gradle: Could not determine java version from '11.0.2'](https://stackoverflow.com/questions/54358107/gradle-could-not-determine-java-version-from-11-0-2) – tryman Apr 03 '19 at 18:55

1 Answers1

5

From your report, your project is using Gradle 2.8 which was released in October 2015.

Because of its age and the need to parse Java version strings, it cannot recognise the version from a Java 12 VM.

You will need to either:

  • Install an older Java version compatible with your build tool and the code it builds,
  • Upgrade your Grade build to a more recent version - Gradle 5.4 includes Java 12 support.
  • Run your build with a compatible Java version and update it to fork tasks that would need to run things with Java 12.
Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43