Ant needs tools.jar and unable to find it

2019-03-08 10:17发布

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 to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar

While the path to the jdk is correct, the tools.jar really wasn't there. Is it actually supposed to be there or did I get some config/installation thing wrong?

10条回答
男人必须洒脱
2楼-- · 2019-03-08 10:31
apt install defalut-jdk # this doesn't contain some file, like tools.jar...
apt install openjdk-8-jdk # this contains all files.
查看更多
再贱就再见
3楼-- · 2019-03-08 10:34

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.

查看更多
Root(大扎)
4楼-- · 2019-03-08 10:35

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.)

查看更多
ゆ 、 Hurt°
5楼-- · 2019-03-08 10:38

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

查看更多
祖国的老花朵
6楼-- · 2019-03-08 10:44

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?

查看更多
叛逆
7楼-- · 2019-03-08 10:47

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::")

查看更多
登录 后发表回答