To compile all the files in a directory including subfolders.
Use the following command :
for /R %a in (*.java) do (javac "%a")
Example :
if you have files in folder C:\A with subfolder B and B cotains C folder.
then
C:\A>for /R %a in (*.java) do (javac "%a")
this will compile files in A, B and C folders.