Error fail to find java version
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.
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.
# ./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:
/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.
I am using macOS Catalina (Version 10.15.7) and getting the below error. Unable to find bundled Java version.
My Java Version
gaurav_shar@LP-abc~ % java -version
java version «11.0.10» 2021-01-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.10+8-LTS-162, mixed mode)
gaurav_shar@LP-abc ~ % which java
/usr/bin/java
gaurav_shar@LP-abc ~ % which javac
/usr/bin/javac
gaurav_shar@LP-abc ~ % javac -version
javac 11.0.10
gaurav_shar@LP-abc ~ %flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on Mac OS X 10.15.7 19H524 darwin-x64,
locale en-IN)
• Flutter version 2.2.3 at /Users/gaurav_shar/Study/flutter/flutter
• Framework revision f4abaa0 (5 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
• Android SDK at /Users/gaurav_shar/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at:
/Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment 18.9 (build
11.0.10+8-LTS-162)
• All Android licenses accepted. [!] Xcode — develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side’s plugin
code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see
https://guides.cocoapods.org/using/getting-started.html#installation for
instructions. [✓] Chrome — develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [!] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio. [✓] VS Code (version 1.58.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.24.0 [✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 83.0.4103.106
! Doctor found issues in 2 categories.
So this is quite simple to solve.
Goto http://www.oracle.com/technetwork/java/javase/downloads/index.html and download the latest jdk for your architecture x32 or x64.
Install as usual and then goto Control Panel -> “Advanced System Settings”
Click on the “Enviroment Variables” and under “System Variables” click “New..”
Then create a new entry with Variable Name: “JAVA_HOME” and Variable Value: “C:Program FilesJavajdk1.7.0_21” (this differs according to the version and system).
Источник
Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to check gradlew version But I am facing following error Could not determine java version from ‘11.0.2’ in Java. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
- How this Error Occurs ?
- How To Solve Could not determine java version from ‘11.0.2’ Error ?
- Solution 1: upgrade wrapper
- Solution 2: Update distributionUrl
- Summary
Could not determine java version from ‘13.0.1’
I have gradle 6.0.1 and JDK 13.0.1 installed and tried gradlew setupDecompWorkspace , but it tells me «Could not determine java version from ‘13.0.1’ «. I’ve tried to find an answer for a week now and I can’t find a solution. edit: the result of gradlew setupDecompWorkspace —stacktrace : https://pastebin.com/NFqZpBkG edit 2: i manually changed the wrapper.properties file and updated my gradle wrapper. Now gradlew setupDecompWorkspace —stacktrace gives me this: https://pastebin.com/ubYj4Zq0
Kindly post result of gradlew setupDecompWorkspace —stacktrace , feels like issue with minecraft code and not Gradle.
3 Answers 3
I installed jdk 13 and call react-native run-android, then get error above.
Solution: Check if you have jdk 13 here: /Library/Java/JavaVirtualMachines/
ls /Library/Java/JavaVirtualMachines/
cd /Library/Java/JavaVirtualMachines/ sudo rm -rf jdk-13.0.0 // your version
After that reinstall jdk-8 again.
When I run your command (sudo rm -rf adoptopenjdk-13.0.1) and build my app using gradle (./gradlew cC), I see adoptopenjdk-13.0.1 is re-installed 😟
Gradle didn’t support Java 13 (without forking the compiler) until Gradle 6.0. You say that is the one you have installed, but you are not supposed to install anything when using the Gradle wrapper. Rather, the wrapper will download the version of Gradle that is defined in the gradle-wrapper.properties file.
If you run gradlew —version (and remember to use the ‘w’ version), there is a good chance you will see an older version. If so, either upgrade the wrapper with gradle wrapper —gradle-version 6.0.1 —distribution-type all (or newer), or downgrade Java.
if i run gradlew —version , all i get is «Could not determine java version from ‘13.0.1’ «. And is i try gradle wrapper —gradle-version 6.0.1 —distribution-type all , i get a «Build failed with an exception» and a text telling me the problem occured in my build file in line 18 and that it couldn’t evaluate the root project from minecraft forge. what exactly do you mean by downgrade java? because i have java 8 and JDK 13, and i cant download an older version of JDK, as i dont have an oracle account
I meant downgrading from Java 13 to Java 8 (or 11) by setting your JAVA_HOME property. I don’t know what Minecraft Forge support. But you can try just changing the file gradle/wrapper/gradle-wrapper.properties manually so the distributionUrl reads distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip (newest at the time of writing) and try giving it a go with Java 13.
I was having the same issue. 1.7.10 forge does not support gradle 6. In the \gradle\wrapper\gradle-wrapper.properties revert the gradle version to what it was before it is something like 4.x. (This is for 1.8.9 not 1.7.10 if it is 3.x maybe try JDK 7 instead of 8 if the same error occurs)
Gradle 4 does not support JDK 13. I am not sure what versions work for gradle 4 as I cannot find the documentation for the supported versions. After some trial and error, I found JDK 8 works. Download and install here.
After the installer is complete, it won’t just work. You will need to set «JAVA_HOME». Go to your environment variabes (Control Panel\System and Security\System\Advanced system settings\Advanced\Environment Variables. ) If «JAVA_HOME» doesn’t exist in the system variables, create it. Call it «JAVA_HOME» and set the value to «C:\Program Files\Java\jdk1.8.0_241» if you used the installer I linked. After you have done this, click ok, ok, ok and close the control panel.
You are almost done! Now all you have to do is restart your computer and it should work. If it doesn’t comment on this answer and @ me. Hope it works.
Note: I recommend to use IntelliJ for modding and once you have decompiled, open the build.gradle with IntelliJ. Wait for it to load and then go back to your command prompt and type «gradlew genIntellijRuns» (as seen in github guide for modding)and now you are ready to start coding!