Ant needs tools.jar and unable to find it

后端 未结 10 1902
温柔的废话
温柔的废话 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:00

    Even if you have jdk installed, you'll need to redirect JAVA_HOME to point to it.

    Here's one weird trick you can put into your .profile to set JAVA HOME properly, no matter which java you have:

    export JAVA_HOME=$(dirname $(dirname $(readlink -e /usr/bin/java)))
    # Test for jdk installed above jre
    if [ -x $JAVA_HOME/../bin/java ]; then export JAVA_HOME=$(dirname $JAVA_HOME); fi
    
    0 讨论(0)
  • 2021-01-30 17:01
    apt install defalut-jdk # this doesn't contain some file, like tools.jar...
    apt install openjdk-8-jdk # this contains all files.
    
    0 讨论(0)
  • 2021-01-30 17:04

    It's there on my machine. I'm running Sun JDK 1.6.0_21 on Windows XP SP3.

    Are you sure you have the JDK? Is it possible that you only have the JRE?

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

    Note: On CentOS / RHEL installing java-1.x.0-openjdk will not be enough. Also install java-1.x.0-openjdk-devel.

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

    On Ubuntu I've just need to install JDK sudo apt-get install openjdk-7-jdk

    ..and you can always search for all available versions with

    $ sudo apt-cache search openjdk | grep ^openjdk
    

    From the website https://openjdk.java.net/install/ we can read

    The openjdk-7-jre package contains just the Java Runtime Environment. If you want to develop Java programs then install the openjdk-7-jdk package.

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

    On Ubuntu I've fixed this problem by installing package

    openjdk-7-jre-lib
    

    tools.jar appeared after that.

    (I know this is an old post, but comment in hope that it will be helpful for somebody lurking for answer like I was today.)

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