0

First I have installed ant and java and ant can build success in terminal.

Then my work need to start a cron job, to check a build queue every minutes and the run ant build.

So I create a build.sh file, code like this:

#run ant on build path
ANT_CMD=/opt/apache-ant/bin/ant
JAVA_HOME=/opt/jdk1.6.0_03/

cd /mnt/tmp/webview/

$ANT_CMD -f /mnt/tmp/webview/build.xml > /mnt/tmp/$$out.log > /mnt/tmp/$$err.log

And I use sudo crontab -e start an cron like this:

*/1 * * * * bash /mnt/tmp/build.sh

Last I got info on the err.log file like this:

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64/lib/tools.jar
Buildfile: /mnt/tmp/webview/build.xml

init:
    [echo] Initializing all output directories...
    [delete] Deleting directory /mnt/tmp/webview/bin
    [mkdir] Created dir: /mnt/tmp/webview/bin

gen-R:
    [echo] Generating R.java from the resources...

I use find / -name tools.jar can be found on /opt/jdk1.6.0_03/lib/tools.jar

My thought is in the bash file ant don't know the JAVA_HOME I'm set.

Does anyone know about this, pls help me!

Wayn Liu
  • 394
  • 3
  • 13
  • try `export JAVA_HOME="/opt/jdk1.6.0_03/"`, then `export LD_LIBRARY_PATH=${JAVA_HOME}/lib:$LD_LIBRARY_PATH` – iamauser Sep 04 '13 at 02:24
  • New Progress, thanks for help, I'm use export JAVA_HOME in the build.sh. the error log do not show the first line, but always not build success – Wayn Liu Sep 04 '13 at 02:25
  • @iamauser, thanks your help, I'm use your code but not work, the build now seems always stop on Generating R.java from the resources... – Wayn Liu Sep 04 '13 at 02:40
  • Hi, every one I solved this issue, I change the path on the build.xml file, my build.xml use the android-sdk, so i change the android-sdk env to use the direct path, so it works. Does this means the base file can not know all the env path. We must specify the direct path to use all command. – Wayn Liu Sep 04 '13 at 03:05
  • IMHO, this question has been wrongly marked as a duplicate of 5730815, as 5730815 relates to Windows systems and this question relates to CentOS sytems. http://stackoverflow.com/questions/18061887/where-is-tools-jar-located/18061960 provides further answers – Abdull Dec 10 '13 at 23:43

0 Answers0