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.
Fix:
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!
More Posts related to Gradle,
- Run only a Single Unit Test using Gradle
- Run IntelliJ Java main method without Gradle build
- How to force re-download Gradle Dependencies
- How to Run Gradle Build Without Unit Test Cases
- Find installed Gradle version command
- Fix: Invalid Gradle JDK configuration found. Could not find the required JavaSDK
- Generate Project Dependency tree using Gradle Command
- Installing Gradle on macOS - Gradle Tutorial
- Gradle FAILURE: Build failed with an exception - Task not found in root project
- [Fix] ./gradlew: Permission denied
- Force Gradle to use specific Java JDK Version
- [fix] Deprecated gradle features were used in this build, making it incompatible with Gradle X.0
- Create a Gradle Java Project in VS Code
- Install Gradle VS Code for Java Projects
- Fix: Unsupported Java. Your build is currently configured to use Java 17.0.5 and Gradle 7.1.
- How to create Gradle Multi-Project in IntelliJ
- Fix: Spring Boot + IntelliJ + Gradle : Unsupported class file major version 64 Error
- Fix: Error: Could not find or load main class org.gradle.wrapper. GradleWrapperMain
- [fix] bash: gradlew: command not found
- [fix] Execution failed for task :core:compileJava - Could not find tools.jar
- Run Gradle Build without test cases
- How to add maven central repository in build.gradle
- Upgrade Gradle in Android Studio
- Task is ambiguous in root project gradle-examples. Candidates are: myTask1, myTask2
- Fix: Deprecated Gradle features were used in this build, making it incompatible with Gradle
More Posts:
- Java 8 foreach loop code examples - Java
- Fix: AssertionError in Python - Python
- Android R Cannot Be Resolved To A Variable - Android
- Android Studio SDK Build-tools 23 rc2 not getting installed - Android-Studio
- Fix - Microsoft Windows Error Code: 0xA00F4244 NoCamerasAreAttached - Microsoft
- Shortcut: Cut (or Delete) current line in Visual Studio Code (VSCode) - HowTos
- Hide Scrollbar from Android Views - Android
- Bash Command to Find OS Version in Terminal - Bash