[fix] Execution failed for task :core:compileJava - Could not find tools.jar

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ":core:compileJava'

> Could not find tools.jar

If you get the above error when you try to build and run your Java Gradle-based project, the reason is tools.jar is not accessible.


Open the build.gradle file of your project and make sure you have provided the property sourceCompatibility correctly.

Example for Android Studio Project:
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8

Note: Make sure Java JDK is installed on your device, if not get it installed.

Also make sure that JAVA_HOME is set in zshrc or bash profile file.

export JAVA_HOME=/path/to/java-jdk

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap