I’m working on an update to a legacy build process that I want to move to ant. When I got to my first test, “Does it do anything if I run it against a skeleton build.xml on this machine?”, I found my first error (warning, if you want to be pedantic).
D:\BuildNG>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
Buildfile: D:\BuildNG\build.xml
help:
[echo] Common build targets:
[echo] jar - Builds testconsole.jar
[echo] build - Same as clean+jar
[echo] compile - Compiles TestConsole classes
[echo] clean - Remove all *.class and testconsole.jar
BUILD SUCCESSFUL
Total time: 0 seconds
In retrospect, the problem should have been clear to me. However, that would have only been the case had I read the entire error message rather than stopping at the first full stop and starting a search for tools.jar.
Searching through some threads over at stackoverflow.com, I came across many folks suggesting that it was an environment problem. Checking my JAVA_HOME variable seemed to confirm that at first.
D:\BuildNG>echo %JAVA_HOME%
%JAVA_HOME%
However, I still hadn't found a copy of tools.jar anywhere that I might have expected. At this point, I suddenly had one of those head-smacking, "what was I thinking?" insights. Usually, if I'm doing Java development, I'm doing it in a VM. I had never installed a JDK on the machine where I was testing the invocation! I installed the latest JDK and set JAVA_HOME. Problem solved, world saved.
The takeaway lesson is to always check the basic things. “Do I actually have the JDK installed?” is about the same level of question as “Is it plugged in? Is it turned on?” Sometimes, though, it’s exactly the question to ask.
ICF Ironworks is always on the lookout for experienced professionals who believe in hard work, having fun, and great client service.
I have JRE and JDK installed. echo %JAVA_HOME% gives %Program Files%\Java\jdk1.6.0_26 which is correct, inside of it lib folder that contains tools.jar file. But "ant" stubbornly says "Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
b\tools.jar". Do you have any ideas how to configure this?
Posted by: Maxim | 08/14/2012 at 05:23 PM
Maxim, what does your CLASSPATH look like? Actually, why don't you do a "set" so we can see all your environment variables.
Posted by: Rob Huffstedtler | 08/15/2012 at 10:54 AM