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