Ant needs tools.jar and unable to find it

后端 未结 10 1905
温柔的废话
温柔的废话 2021-01-30 16:27

I am putting together a dev environment for a Java program and after the first try of my Ant build scripts I got this error:

Unable to locate tools.jar. Expected         


        
相关标签:
10条回答
  • 2021-01-30 17:11

    On Debian, after installing Ant with apt-get install ant, I've encountered the same error when running it:

    Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar

    Indeed, there's no mention of any tools.jar anywhere in /usr/lib, although /usr/lib/jvm/java-6-openjdk-amd64 itself does exist.


    https://packages.debian.org/search?searchon=contents&keywords=java-6-openjdk-amd64%2Flib%2Ftools.jar

    As per the search above, java-6-openjdk-amd64/lib/tools.jar appears to be part of openjdk-6-jdk, which indeed didn't get installed with ant (since it's only marked as suggested (https://packages.debian.org/wheezy/ant)).

    apt-get install openjdk-6-jdk

    0 讨论(0)
  • 2021-01-30 17:11

    Try the following:

    % sudo apt-get install sun-java6-jdk

    % sudo update-alternatives --config java

    select the option that has the path

    /usr/lib/jvm/java-6-sun/jre/bin/java

    Worked for me on an ubuntu 10.4

    u can try to put your JAVA_HOME also, as follows:

    % sudo export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")

    0 讨论(0)
  • 2021-01-30 17:16

    It seems like you can have Java installed in /usr/lib/jvm/java-6-openjdk but only have the JRE, not the JDK. This fixed it for me:

    sudo apt-get install openjdk-6-jdk

    0 讨论(0)
  • 2021-01-30 17:17

    Installing the jdk-6u45-linux-x64.bin (from the oracle.com site) via unzip does not result in a tools.jar. I guess that file is created by the "make-jpkg" script. Once I did that, and installed the resulting .deb file, everything was fine. I really hate oracle's lawyers.

    0 讨论(0)
提交回复
热议问题