How can I recursively grep particular files in a directory?

Solution 1:

find . -name '*.java' | xargs grep <your pattern here>

Solution 2:

There is a tool specially designed for this type of need: ack.

ack is a tool like grep, aimed at programmers with large trees of heterogeneous source code

Also read the "Top 10 reasons to use ack instead of grep." at the ack page.