Jack Wilson
Jack Wilson

Reputation: 6255

Could not determine Java version using executable C:\Program Files\Java\jdk-10.0.1\bin\java.exe

Could not determine Java version using executable C:\Program Files\Java\jdk-10.0.1\bin\java.exe.

This error appeared when I tried to create a new project in IntelliJ IDEA Version 2018.1.2 with Gradle. It said:

sync failed: Could not determine Java version using executable C:\Program Files\Java\jdk-10.0.1\bin\java.exe

==================

I fixed the problem by uninstalling jdk 10 and installing jdk8.

Upvotes: 50

Views: 69403

Answers (11)

Abdallah Mahmoud
Abdallah Mahmoud

Reputation: 937

USE SAME ANDROID STUDIO JAVA VERSION

STEPS WINDOWS

  1. the java version found at path
C:\Program Files\Android\Android Studio\jbr
  1. we need to edit enviroment variable of "JAVA_HOME" to be equal "C:\Program Files\Android\Android Studio\jbr" you can set from cmd by open as adminstartor, then write this command:
setx -m JAVA_HOME "C:\Program Files\Android\Android Studio\jbr"
  1. test by echo the JAVA_HOME from cmd
echo %JAVA_HOME%

4- Restart Android Studio, then call this command from termnial.

flutter doctor --android-licenses

Upvotes: 0

Hassan Badawi
Hassan Badawi

Reputation: 302

same in mac == Could not determine Java version using executable /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/bin/java. this help me

cd /Library/Java/JavaVirtualMachines

then run

sudo rm -rf jdk-11.0.2.jdk

after that try to build

it will request SDK select it from Contents

Upvotes: 0

S34N
S34N

Reputation: 8371

Even if you're using Linux the solution remains the same.

Inside the root folder of your Project(Working Directory) >>

gradle/wrapper/

There's a file named >>

gradle-wrapper.properties

Change the distributionUrl line (Outdated Version):

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip

To the following distributionUrl (Compatible/Correct Version):

distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip 

Don't forget to configure IntelliJ IDEA Settings to use the Gradle-Wrapper Configurations.

Upvotes: 13

Mindaugas Bernatavičius
Mindaugas Bernatavičius

Reputation: 3909

Going to:

File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle

and selecting:

Use local gradle distribution

fixed it for me.

Upvotes: 6

Alif
Alif

Reputation: 1135

Solution summary:

  • Turn back to older version of jdk
  • Remove problematic jdk(s) from intelliJ

A full demonstration is given below for intelliJ in ubuntu 18.04.1

enter image description here

fig1: Installing openjdk-8.

enter image description here

fig2: Adding jdk8 to Project Structure. Click + button then choose JDK. Now choose JDK home path to jdk8. Mine was, as you can see from fig3, /usr/lib/jvm/java-1.8.0-openjdk-amd64

enter image description here

fig3: openjdk-8 is added to intelliJ. [a:] Time to remove newer versions of jdk from intelliJ.

enter image description here fig4: Select 10 (notice that the JDK home path contains java-1.11.0-openjdk-amd64) and press - button to remove 10.

enter image description here fig5: after removal of jdk-10 select jdk-8(named 1.8 in fig5) and press ok.

enter image description here fig6: Now go to File->Settings->Build, Execution, Deployment->Build tools->Gradle->Gradle JVM and choose the same path that you have set as JDK home path while adding 1.8 in Project Structure and press Ok. Click Build and choose Make new module app and the app module should be created. Now if pressing Run and choosing app module gets your app running, you have a good day :) and if not, recheck activities mentioned in fig3[a] & fig6 once.

Upvotes: 7

M. Solomonik
M. Solomonik

Reputation: 71

After downloading my latest Gradle version and changing the path environment variable to C:\Gradle\gradle-4.10-bin\gradle-4.10\bin, not what was on the instructions, and changing to "Use local gradle distrubution" under Settings- Build, Execution, Deployment - Gradle It worked for me.

Upvotes: 1

Nafeez Quraishi
Nafeez Quraishi

Reputation: 6158

Below is what i did to solve this issue on Windows 10 with IntelliJ 2018.1.5 and Java 10.0.1 JDK

  1. Downloaded the new gradle version(latest is 4.8.1 at the time of this post) from: https://gradle.org/releases
  2. Followed the following steps mentioned at: https://gradle.org/install/

(i) Microsoft Windows users

Create a new directory C:\Gradle with File Explorer.

Open a second File Explorer window and go to the directory where the Gradle distribution was downloaded. Double-click the ZIP archive to expose the content. Drag the content folder gradle-4.8.1 to your newly created C:\Gradle folder.

(ii) Added PATH C:\Gradle\gradle-4.8.1\bin to environment variable

  1. After above went to File --> Settings-->Build Tools --> Gradle and did set Gradle home to C:/Gradle/gradle-4.8.1

  2. Then went to View --> Tool Windows --> Gradle and hit the Refresh all Gradle projects icon.

Upvotes: 10

Zosia Czerniawska
Zosia Czerniawska

Reputation: 1

I had similar issue with IntelliJ version2018.1.6 x64. I installed Java8 and the problem disappeared.

Upvotes: 0

Luka Lopusina
Luka Lopusina

Reputation: 2647

For JDK 10 you will need Gradle 4.7+ which is not used by default in IntelliJ IDEA (current version IntelliJ IDEA 2018.1.4).

To fix this issue install latest Gradle for your OS (Install guide). For MacOS you can use Homebrew:

brew install gradle

Go to your project directory:

cd ~/path/to/your/project/

Generate Gradle Wrapper script with the version you installed (in my case it is 4.8):

gradle wrapper --gradle-version 4.8

This command is going to download Gradle 4.8, create scripts gradlew and gradlew.bat for your current project. From this point, you should use these scripts in the command-line.

Next step, is to make sure that IntelliJ IDEA uses those, instead of built-in Gradle distribution and you can do this by opening IntelliJ preferences and search for "gradle" (this will be in "Build, Execution, Deployment / Build Tools / Gradle").

In this section of the settings select:

Select “Use gradle ‘wrapper’ task configuration”

Apply changes, press ok and re-build (re-sync) Gradle and everything should be fine. I hope this helps.

Upvotes: 64

i had to un-install my intelliJ along with cache and all histories, remove my project... Then i re-installed intellij and downloaded my project's fresh version again.

As a last step, i had to define new sdk for my project. Previously, it was showing 2-3 SDKs. after re-installation, there were none. i added one. To add SDK in Intellij: Go to- File- Project Structure- Project Settings- Project SDK...

Added one sdk here to point to the jdk installed path.

Upvotes: 0

JavaCafe01
JavaCafe01

Reputation: 162

It's most likely your gradle version. Gradle 4.7+ has JDK 10 support.

Upvotes: 2

Related Questions