Monday, September 23, 2019

Gradle Complaining about JDK not Found

I was attempting to compile a Kotlin project, and encountered the following error:


* What went wrong:

Execution failed for task ':compileKotlin'.

> Kotlin could not find the required JDK tools in the Java installation 'C:\Program Files\Java\jre1.8.0_211' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
The answer to the problem is straightforward is to inform Gradle where the JDK is. Since I am on a Windows host, and the host has had these installed:

C:\>dir "C:\Program Files\Java\"
....

05/14/2019  09:58 AM    <DIR>          .
05/14/2019  09:58 AM    <DIR>          ..
03/04/2019  09:39 PM    <DIR>          jdk-11.0.2
03/04/2019  09:29 PM    <DIR>          jdk1.8.0_201
05/12/2019  08:32 PM    <DIR>          jre1.8.0_211
.....

C:\>

I added the following line to the gradle.properties file, and the problem went away,

org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_201

2 comments:

  1. # [Solved]
    1. Download **Gradle** from [here](https://gradle.org/) **OR** from [Direct link](https://services.gradle.org/distributions/gradle-6.5.1-bin.zip)
    2. Unzip the downloaded file in `C://`
    3. Update the /bin path in `System Environment Variables`
    *Run the program and check if the problem is fixed? Proceed next if you still got the error(s)*
    4. Download **Java SE Runtime Environment 8u261** [here](https://www.oracle.com/java/technologies/javase-jre8-downloads.html)
    5. Update the /bin path in `System Environment Variables`
    *This will fix the issue. Lemme know if you still got errors*

    ReplyDelete
  2. it still didnt worked for me

    ReplyDelete