How to find the number of errors(marked in red) in an eclipse project programmatically?
There are two major steps:
You need an access to Eclipse API - write your own plugin for Eclipse or use a scripting plugin like Groovy Monkey
Using Eclipse API get problem markers for resource you intrested in - check this link: How to work with resource markers
If you want to retrieve only JDT error markers you should write something like this:
public static IMarker[] calculateCompilationErrorMarkers(IProject project)
{
ArrayList result = new ArrayList ();
IMarker[] markers = null;
markers = project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
for (IMarker marker: markers)
{
Integer severityType = (Integer) marker.getAttribute(IMarker.SEVERITY);
if (severityType.intValue() == IMarker.SEVERITY_ERROR)
result.add(marker);
}
return result.toArray(new IMarker[result.size()]);
}