Question: I am asked to develop a software which should be able to create Flow chart/ Control Flow of the input Java source code. So I started researching on it and arrived at following solutions:

To create flow chart/control flow I have to recognize controlling statements and function calls made in the given source code Now I have two ways of recognizing:

1. Parse the Source code by writing my own grammars (A complex solution I think). I am thinking to use Antlr for this.
2. Read input source code files as text and search for the specific patterns (May become inefficient)

Am I right here? Or I am missing something very fundamental and simple? Which approach would take less time and do the work efficiently? Any other suggestions in this regard will be welcome too. Any other efficient approach would help because the input source code may span multiple files and can be fairly complex.

I am good in .NET languages but this is my first big project in Java. I have basic knowledge of Compiler Design so writing grammars should not be impossible for me.

Sorry If I am being unclear. Please ask for any clarifications.

Answer: 
I'd go with [Antlr](http://www.antlr.org/) and use an existing Java grammar: <https://github.com/antlr/grammars-v4>
Our [DMS Software Reengineering Toolkit](http://www.semanticdesigns.com/Products/DMS/DMSToolkit.html) is general purpose program analysis and transformation machinery, with built in capability for parsing, building ASTs, constructing symbol tables, extracting control and data flow, transforming the ASTs, prettyprinting ASTs back to text, etc.

DMS is parameterized by an explicit language definition, and has [a large set of preexisting definitions](http://www.semanticdesigns.com/Products/FrontEnds).

DMS's [Java Front End](http://www.semanticdesigns.com/Products/FrontEnds/JavaFrontEnd.html) already computes [control and data flow graphs](http://www.semanticdesigns.com/Products/DMS/FlowAnalysis.html), so your problem would be reduced to exporting them.

EDIT 7/19/2014: Now handles Java 8.