Originally, I had both NetBeans and Java installed under C:\Program Files\j2sdk_nb. However, after trying to install Sun's web service pack v.1.3, I found that ant wouldn't work right. It said that it couldn't find tools.jar in some directory, and then listed a number of them. One of them was "Files\j2sdk_nb\...", which led me to suspect that the space in "Program Files" was causing it to break. I redownloaded netbeans, installed it and java into a directory structure without spaces, re-installed the web services pack, and everything worked fine. I'm sorry I can't be more specific as to the error.
If this is the version of Ant that sun shipped, it is out of our hands. They modified the ant.bat and so have to live by their actions. Current official Apache Ant releases should not have this defect, so please try one of the versions we offer.
As Steve says this is a netbeans issue.