Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant build : unable to locate tools.jar. Expected find it in C:\Program Files\Java\jre7\lib\tools.jar

I know that this question is popular, but no one of solutions can help me. I used this, this, this and this solutions, but no one help me.

I want to implement uiautomator Tests and need to build my build.xml with ant, but get this strange error.

I use Windows 8.1

My JAVA_HOME system variable set to c:\programs files\java\jdk1.7.0_51 and to c:\programs files(x86)\java\jdk1.7.0_51

My PATH system variable set also to %JAVA_HOME%/bin, my %ANT_HOME% is set to c:\apache-ant.

But when I execute ant build in the android app derictory I get the

unable to locate tools.jar. Expected find it in C:\Program Files\Java\jre7\lib\tools.jar BUILD FAILED Perhaps JAVA_HOME does not point to the JDK 

But my JAVA_HOME points to right JDK ! I confused with this. I also rebuild my build several times, I've got the same.

Will be glad if somebody help me.

like image 215
Rikki Tikki Tavi Avatar asked Feb 24 '14 14:02

Rikki Tikki Tavi


People also ask

Where can I find tools jar in JDK?

Ant expects the tools. jar file to be in the %JAVA_HOME%/lib but tools. jar is distributed with the JDK.

Can not determine path to Tools jar?

The problem is with version of JDK you are using. The Intellij version 2020.2 supports only upto JDK 14. So either you have to lower the JDK version to 14 or update the IntelliJ to a newer version like 2021.

What is the use of tools jar in Java?

The jar tool combines multiple files into a single JAR archive file. jar is a general-purpose archiving and compression tool, based on ZIP and the ZLIB compression format. However, jar was designed mainly to facilitate the packaging of java applets or applications into a single archive.


2 Answers

I too had this problem and solved it by setting variables like this :

[1] ANT_HOME - C:\apache-ant-1.9.3  [2] JAVA_HOME - C:\Program Files\Java\jdk1.7.0_21  [3] PATH - D:\Android_Development\android_sdk\platform-tools\;%ANT_HOME%\bin;%JAVA_HOME%\bin;D:\Android_Development\android_sdk\tools 

Note : Set all these in System variables not in user variables.

This solved my problem.

Hope it helps.

like image 103
Smriti Avatar answered Oct 19 '22 23:10

Smriti


To Recover this problems you can just copy the tools.jar from "C:\ProgramFiles\Java\jdk1.7.0\lib" directly into "C:\Program Files\Java\jre7\lib\".You will successfully recover the problems.

It works!..

like image 25
geek_sandeep Avatar answered Oct 20 '22 00:10

geek_sandeep