I found this question trying to build my project using Ant in Eclipse, and I would get the same error message as above. The suggestions in @Parth’s and other answers to edit the Installed JREs is the first step. What I also needed to run Ant successfully was
- Right click on build.xml, select “Run As”, select “Ant Build…” (note the …)
- Click on the JRE tab
- Change the Runtime JRE to the same thing that you updated in the first stage, and press Apply. (That is, the runtime JRE as you specified by “Preferences” -> “Java” -> “Installed JREs”, as in @Parth’s answer.)
Otherwise it seems that Ant will still try to build with the old JRE that doesn’t have tools.jar. Hope this helps someone.