Ant uses JRE instead of JDK, although environment variables are set

I am using Windows 7 x64 and I am trying to install Apache Ant. I always get the following error message:

C: \ Users \ xxx> ant Cannot find tools.jar. It was expected to find it in C: \ Program Files \ Java \ jre6 \ li b \ tools.jar Buildfile: build.xml does not exist! Build error

Different forums say that environment variables are set incorrectly. I installed them in my system as follows:

ANT_HOME: C: \ Ant

CLASSPATH: C: \ Program Files \ Java \ jdk1.6.0_21 \ bin

JAVA_HOME: C: \ Program Files \ Java \ jdk1.6.0_21 \ bin

Way: (... many things ...); C: \ Program Files \ Java \ jdk1.6.0_21 \ bin; C: \ ant \ bin;% JAVA_HOME% \ bin;

But I still get the error. Do you know how to force ant to use the correct directory? Java (both JRE and JDK) are displayed in Program Files and Program Files (x86). And it seems to be trying to use the 64x JRE.

+4
source share
5 answers

JAVA_HOME should be C: \ Program Files \ Java \ jdk1.6.0_21 \ (remove "bin"), and tools.jar will be in lib, not bin.

+5
source

Check the "many things" path - one of them probably has a java executable.

+1
source

In the area (... a lot of things ...) do you have a path to the JRE? Try to remove it. In addition, instead of using% JAVA_HOME% in your path, you can try setting the full path (thought it should work, I had problems before).

Finally, for JAVA_HOME remove \ bin

+1
source

I know this is an old post, but the link to this post is here:

http://ant.apache.org/manual/

He claims not to set the class path, because Ant can break things out of confusion. If this happens, then to ignore it, add the following:

<property environment="env."/> <property name="env.CLASSPATH" value=""/> <fail message="Unset $CLASSPATH / %CLASSPATH% before running Ant!"> <condition> <not> <equals arg1="${env.CLASSPATH}" arg2=""/> </not> </condition> </fail> 

I hope that all this helps if someone stumbles about it, like me.

0
source

I know this is an old post, but followind helped in JAVA_HOME replace "Program Files" → "Progra ~ 1"

0
source

Source: https://habr.com/ru/post/1332242/


All Articles