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).
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.
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
[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
Total time: 0 seconds
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.
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.