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,
- Task is ambiguous in root project gradle-examples. Candidates are: myTask1, myTask2
- How to create Gradle Multi-Project in IntelliJ
- Find installed Gradle version command
- Adding Jackson dependency to Java Gradle Project
- Gradle FAILURE: Build failed with an exception - Task not found in root project
- Create a Gradle Java Project in VS Code
- Generate Project Dependency tree using Gradle Command
- Fix: Spring Boot + IntelliJ + Gradle : Unsupported class file major version 64 Error
- Fix: Unsupported Java. Your build is currently configured to use Java 17.0.5 and Gradle 7.1.
- Run IntelliJ Java main method without Gradle build
- Fix: Deprecated Gradle features were used in this build, making it incompatible with Gradle
- Installing Gradle on macOS - Gradle Tutorial
- Fix: Invalid Gradle JDK configuration found. Could not find the required JavaSDK
- How to Clear Gradle Cache on Mac
- How to run Gradle build in offline mode
- Install Gradle VS Code for Java Projects
- How to add maven central repository in build.gradle
More Posts:
- How to Uninstall Android Studio on Mac - Android-Studio
- [Fix] Springboot: Web application could not be started as there was no ServletWebServerFactory bean defined in the context. - Java
- Sign in as different user missing in SharePoint 2013 how to enable - SharePoint
- Java JDBC Batch Update Example with PreparedStatement - Java
- Calculate Volume of Pyramid - C-Program
- Change Google Chrome Browsers default download location - Chrome
- [Solution] IDEA IntelliJ System.out.println function shortcut (sysout alternative for eclipse IDE) - HowTos
- Closest Alternate to Notepad on Mac - MacOS