You can possibly take the tools.jar and use it. javac is open source so you can just grab that code (assuming you can deal with the license). Antlr has grammars for Java as well.
2.1m questions
2.1m answers
60 comments
57.0k users