1

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.

1
  • 1
    Class org.xml.sax.helpers.DefaultHandler is for parsing XML files with a SAX parser; it does not have anything at all to do with parsing Java source files. Commented Oct 6, 2011 at 19:27

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

If you are writing an Eclipse plugin, then you will want to use org.eclipse.jdt.core.dom.ASTParser. See the documentation for how to use it. You need to pass it some source, and then call the getMessages method on the resulting org.eclipse.jdt.core.dom.CompilationUnit instance.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.