java build_error ai_generated true

Execution failed for task ':compileJava' > Could not find tools.jar. Please check that /usr/lib/jvm/java-11-openjdk-amd64 contains a valid JDK installation.

ID: java/gradle-task-execution-failure

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-05-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8+ active

Root Cause

The Java home path points to a JRE instead of a JDK, or the JDK installation is incomplete.

generic

中文

Java 主目录路径指向 JRE 而非 JDK,或 JDK 安装不完整。

Workarounds

  1. 95% success Set JAVA_HOME to a proper JDK installation
    export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 (ensure it points to JDK, not JRE)
  2. 90% success Install a full JDK if missing
    sudo apt-get install openjdk-11-jdk

Dead Ends

Common approaches that don't work:

  1. Setting JAVA_HOME to a JRE directory 95% fail

    JRE does not contain tools.jar, which is needed for annotation processing or certain plugins.

  2. Downloading tools.jar separately and placing it in the JRE lib folder 90% fail

    This is not a supported configuration and may cause compatibility issues.