In Netbeans go to Preferences -> Java -> Ant. If your on an older version of Netbeans, the Ant tab may be under Preferences -> Miscellaneous -> Ant. At the very top it should have a label saying something like "(Apache Ant(™) version 1.93 compiled on 2/14/2014)". If the version is below 1.9, then you must update it as it is not compatible with Java 8.
It is most likely sufficient just to update to the latest version of Netbeans which comes with Apache Ant version 1.92. Or if you want to update the Ant version there is already a detailed stack overflow answer.