$show=/label

Gradle - could not determine java version 11.0.8 or any version [Fixed]

SHARE:

A quick guide to fix could-not-determine-java-version when working with Gradle tool for any Gradle version.

1. Overview

In this tutorial, We'll learn how to fix the gradle error "could not determine java version" from 9.0.1, 11.0.8, 11.0.12, 13.0.2, 14.0.2, 15.0.1 or 16.0.1 or any versions.

This is the common error that you face when working with the Gradle and you have the right java version also on the machine.

This solution will work for any java version or Gradle version.




2. Solutions - Gradle - could not determine java version 9.0.1 or 11.0.12 or any


First, you need to understand the concept clearly then you will fix it on your own when you face it next time.

There are two different groups of Gradle applications on your machine.

A) System-wide or level Gradle: This is used by the application when invoked by the Gradle arguments. this is for all the applications in your machine.
B) Gradle Wrapper: when working with the gradlew command. This is specific to the project level and invoked when you use gradlew commands.

If your system-wide Gradle version is 5.1.1 or above, it returns the 5.1.1 for command 'gradle -version'.

When you call Gradle command you do not see any errors. But when when you run the commands of gradlew then you might see the error reporting the java version 11 or 12 or latest ones not found even though releveant java version is present.

Sample error:
# ./gradlew run

FAILURE: Build failed with an exception.

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

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
root@ubuntu-512mb-sfo1-01:~/KOMORANRestAPIServer# cat build.gradle 

Solution 1:


To fix this error, you need upgrade the GradleW version to the new one using command below.
./gradlew wrapper --gradle-version 6.0.1
After a successful ran of the above command, you can verify the issue is resolved. If yes, you are good.

Otherwise, try the next solution if you see the failures as below.
FAILURE: Build failed with an exception.

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

Solution 2:


Sometimes gradlew upgrade did not take the latest updates and the distribution URL is pointing to the older one.

Instead, you can try updating the property distributionUrl in the gradle-wrapper.properties file.

gradle-wrapper.properties location:
<project-root-directory>/gradle/wrapper/gradle-wrapper.properties

Update the distributionUrl property as below. One of them will work.
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
or 
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
Could not determine java version from '11.0.5'.

Solution 3:

If JAVA_HOME is pointing to the different one then change it to the right one. This will fix the problem.

Solution 4:

If gradle version you are using is not supporting for java 11 or higher then you can alternativly change the java version using the below command.
sudo update-alternatives --config java

Could not determine java version from '11.0.5'.

If you want the latest java version then upgrade the gradle version latest as mentioned in the solutions 1 and 2.

3. Verification


After applying the solution, run the command to verify the issue is resolved or not.
 ./gradlew run
Downloading https://services.gradle.org/distributions/gradle-6.0.1-bin.zip
...........................................................................................................................................................................................................................................................
Unzipping /root/.gradle/wrapper/dists/gradle-6.0.1-bin/1lxlpkiy24sb18odw96cp4ojv/gradle-6.0.1-bin.zip to /root/.gradle/wrapper/dists/gradle-6.0.1-bin/1lxlpkiy24sb18odw96cp4ojv
Set executable permissions for: /root/.gradle/wrapper/dists/gradle-6.0.1-bin/1lxlpkiy24sb18odw96cp4ojv/gradle-6.0.1/bin/gradle

Welcome to Gradle 6.0.1!

Here are the highlights of this release:
 - Substantial improvements in dependency management, including
   - Publishing Gradle Module Metadata in addition to pom.xml
   - Advanced control of transitive versions
   - Support for optional features and dependencies
   - Rules to tweak published metadata
 - Support for Java 13
 - Faster incremental Java and Groovy compilation
 - New Zinc compiler for Scala
 - VS2019 support
 - Support for Gradle Enterprise plugin 3.0

For more details see https://docs.gradle.org/6.0.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

> Task :run



4. Conclusion

In this article, we've shown the 4 ways to fix Gradle - could not determine java version error.



COMMENTS

BLOGGER

About Us

Author: Venkatesh - I love to learn and share the technical stuff.
Name

accumulo,1,ActiveMQ,2,Adsense,1,API,37,ArrayList,18,Arrays,24,Bean Creation,3,Bean Scopes,1,BiConsumer,1,Blogger Tips,1,Books,1,C Programming,1,Collection,8,Collections,37,Collector,1,Command Line,1,Comparator,1,Compile Errors,1,Configurations,7,Constants,1,Control Statements,8,Conversions,6,Core Java,149,Corona India,1,Create,2,CSS,1,Date,3,Date Time API,38,Dictionary,1,Difference,2,Download,1,Eclipse,3,Efficiently,1,Error,1,Errors,1,Exceptions,8,Fast,1,Files,17,Float,1,Font,1,Form,1,Freshers,1,Function,3,Functional Interface,2,Garbage Collector,1,Generics,4,Git,9,Grant,1,Grep,1,HashMap,2,HomeBrew,2,HTML,2,HttpClient,2,Immutable,1,Installation,1,Interview Questions,6,Iterate,2,Jackson API,3,Java,32,Java 10,1,Java 11,6,Java 12,5,Java 13,2,Java 14,2,Java 8,128,Java 8 Difference,2,Java 8 Stream Conversions,4,java 8 Stream Examples,12,Java 9,1,Java Conversions,14,Java Design Patterns,1,Java Files,1,Java Program,3,Java Programs,114,Java Spark,1,java.lang,4,java.util. function,1,JavaScript,1,jQuery,1,Kotlin,11,Kotlin Conversions,6,Kotlin Programs,10,Lambda,2,lang,29,Leap Year,1,live updates,1,LocalDate,1,Logging,1,Mac OS,3,Math,1,Matrix,6,Maven,1,Method References,1,Mockito,1,MongoDB,3,New Features,1,Operations,1,Optional,6,Oracle,5,Oracle 18C,1,Partition,1,Patterns,1,Programs,1,Property,1,Python,2,Quarkus,1,Read,1,Real Time,1,Recursion,2,Remove,2,Rest API,1,Schedules,1,Serialization,1,Servlet,2,Sort,1,Sorting Techniques,8,Spring,2,Spring Boot,23,Spring Email,1,Spring MVC,1,Streams,31,String,61,String Programs,28,String Revese,1,StringBuilder,1,Swing,1,System,1,Tags,1,Threads,11,Tomcat,1,Tomcat 8,1,Troubleshoot,26,Unix,3,Updates,3,util,5,While Loop,1,
ltr
item
JavaProgramTo.com: Gradle - could not determine java version 11.0.8 or any version [Fixed]
Gradle - could not determine java version 11.0.8 or any version [Fixed]
A quick guide to fix could-not-determine-java-version when working with Gradle tool for any Gradle version.
JavaProgramTo.com
https://www.javaprogramto.com/2021/11/could-not-determine-java-version.html
https://www.javaprogramto.com/
https://www.javaprogramto.com/
https://www.javaprogramto.com/2021/11/could-not-determine-java-version.html
true
3124782013468838591
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content