Ant build - Unable to locate tools.jar. Expected to find it in /usr/local/openjdk-11/lib/tools.jar

hello, I am trying to build ant task using gitlab ci file. runner is installed on kubernetes. following are details. I see JAVA_HOME is already set.

Please let me know if I missing anything here. thanks

base image: timbru31/java-node - this node and java image .
when I try to build ant tasks it is failing with following error . I am able to build this project on my local machine without any issue where JAVA and ant already installed on my local.

**error: **

Unable to locate tools.jar. Expected to find it in /usr/local/openjdk-11/lib/tools.jar
Build failed
Buildfile: build.xml does not exist!

below is build job in my gitlab-ci file.

stage: build
image: timbru31/java-node

  • export JAVA_HOME="/usr/local/openjdk-11"
    • echo “building xyz project”
    • echo $JAVA_HOME
    • cd project/xyz
    • npm install
    • apt-get update
    • apt-get -y install openjdk-8-jdk
    • apt-get -y install ant
    • ant my_task


reading this issue it seems that tools.jar was removed in OpenJDK 9+.

Here’s the technical decision for this change, likewise in the Oracle Java docs.

That being said, I’d say you need to rebuild your application’s code against JDK 11. Not sure though what exactly is needed, if it is for ant, follow this recommendation to upgrade to the latest ant version.

If you google for the error, there’s a bunch of topics since this cleanup affects many users.


@dnsmichi thank you for the response.