I would like to be able to parse a .java file and get all the errors, fatal errors, and warnings. Is there a way to do that? I tried to extends DefaultHandler but it seems to encapsulate xml parser error and warning. Any ideas are greatly appreciated.
2 Answers
Look at the package javax.tools. It contains an API to the Java compiler.
The API documentation of interface javax.tools.JavaCompiler has an example that seems to demonstrate what you want: list compilation diagnostics for a source file.
org.xml.sax.helpers.DefaultHandleris for parsing XML files with a SAX parser; it does not have anything at all to do with parsing Java source files.