0

I have some trouble running ANT on Ubuntu. I know that there are tons of posts about it but I've never found a post about proprietary Java. So, when I try to launch ANT, I got this error :

jeff@jeff-X200MA:~$ ant Unable to locate tools.jar. Expected to find it in /opt/jre1.7.0_51/lib/tools.jar Buildfile: build.xml does not exist! Build failed

What can I do to fix that ?

Thank you in advance :), Jeffrey

user2363392
  • 95
  • 1
  • 7

1 Answers1

0

HERE is the entire instructions for installing and running Ant.

  • you need to install jdk (available here) and set the JAVA_HOME environment variable to jdk's installation directory and add %JAVA_HOME%/bin to the PATHvariable. See HERE for setting environment variables.

  • similarly, you need to install Ant and set ANT_HOME environment variable to Ant's installation directory and add %ANT_HOME%/bin to the PATH variable. See the 1st Link, at the start.

  • close any open command-prompt windows, to reflect the changes.


When you need JDK functionality (such as for the <javac> task or the <rmic> task) in Ant, then tools.jar is required. This tools.jar is present in JDK but not in JRE. See JDK and JRE file Structure

currently your JAVA_HOME is pointing to, probably, /opt/jre1.7.0_51 and thus, while running ant it is searching for tools.jar under the /opt/jre1.7.0_51/lib folder. you need to install jdk if you haven't and change JAVA_HOME to point to the installation directory of JDK, for eg. /opt/jdk1.7.0_60.

sunbabaphu
  • 1,473
  • 1
  • 10
  • 15
  • Thank you for your help :) I'm going to test that right now ! – user2363392 Jul 22 '14 at 14:45
  • I have another problem. I've done what you told me to do but when I close my command-prompt window, the terminal doesn't know the java command whereas before I close it, it worked. It's as if the PATH is not saved when I close the window. I've done these commands to change my path : PATH=/opt/jdk1.7.0_65/bin:$PATH export PATH And I've done the same thing for ANT. How can I fix it ? Thanks again for your answer – user2363392 Jul 22 '14 at 15:28
  • See http://blog.manishchhabra.com/2012/05/installing-oracle-sun-java-jdk-and-setting-java_home-in-ubuntu-linux/ – sunbabaphu Jul 22 '14 at 16:00
  • THe path works correctly but I still have the error concerning the build.xml file. How can I fix it ? – user2363392 Jul 22 '14 at 16:12
  • what command do you use to launch the build? (be exact) – sunbabaphu Jul 22 '14 at 16:48