vijay sahu
vijay sahu

Reputation: 815

How to set environment variable for ant

I am trying to build my first android app using phonegap and for that i need jdk environment,node.js,ant. And I am able to install jdk but for Apache ant I have tried many forum and tutorials for setting the path but not able to succeeded on this.

I set my varialbe like this.... Variable Name :- ANT_HOME Variable Value:- C:\JAVA\ant\bin

Variable Name :- JAVA_HOME Variable Value:- C:\Program Files\Java\jdk1.7.0_60\jre\bin\

But still i am getting "unalbe to locate tools.jar. Expected to find in C:\ProgramFiles\java\jre7\lib\tools.jar BuildFile: build.xml doest not exists. Build Failed.

PLEASE HELP ME OUT FROM THIS ANONYMOUS TROUBLES..

Upvotes: 0

Views: 4868

Answers (3)

Naveen Mosuru
Naveen Mosuru

Reputation: 171

This can be done in 2 different ways:

1: From Command Prompt. C:>set ANT_HOME=C:\Program Files\Ant Files\apache-ant-1.10.5

C:>set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181

C:>set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin

C:> ant -version

Apache Ant(TM) version 1.10.5 compiled on July 10 2018

2: By setting environment variables.

Right click on This PC > Properties > Advanced system settings > Environment Variables > User variables > New > Variable name:**ANT_HOME & for **Variable value:**C:\Program Files\Ant Files\apache-ant-1.10.5 > **OK.

Now goto System variables to add bin path. System variables > double click on Path >New > C:\Program Files\Ant Files\apache-ant-1.10.5\bin >New >C:\Program Files\Java\jdk1.8.0_181\bin>OK.

Now lets check whether it is installed correctly or not.

goto Command Prompt > and type ant -version.

C:> ant -version

Apache Ant(TM) version 1.10.5 compiled on July 10 2018

That's it. Let me know if still getting any difficulties.

Upvotes: 0

DavidPostill
DavidPostill

Reputation: 7921

JAVA_HOME should be the JDK installation directory (in your case C:\Program Files\Java\jdk1.7.0_60\. Then you add %JAVA_HOME%\bin to the path.

For java, see Update the PATH Environment Variable (Microsoft Windows).

You can follow a similar procedure to add ANT_HOME to your path. ANT_HOME should be C:\JAVA\ant and then you add %ANT_HOME%\bin to the path.

If echo %PATH% shows the correct values for both ant and java then you need to check your Cordova configuration as it appears your configuration is pointing to a Java Runtime Environment (JRE) instead of a Java Development Kit (JDK).

Upvotes: 0

sunbabaphu
sunbabaphu

Reputation: 1493

See HERE for Ant, jdk, tools.jar related instructions.

  • for Ant:

    ANT_HOME set to C:\JAVA\ant and add ;%ANT_HOME%\bin to the PATH variable

  • for JDK:

    JAVA_HOME set to "C:\Program Files\Java\jdk1.7.0_60\" (with the quotes if you have space(s) in your file path) and add ;%JAVA_HOME%\bin to your PATH variable.

  • close any command-prompt window(s) that were open prior to the changes above. Only command windows opened after the changes will have the updated environment variables.

Upvotes: 0

Related Questions