The javac command-line javac compile every source file specified on the command line, plus everything else they depend on if they don't have newer class files.
The ant javac task tries to be smarter in order to avoid always compiling everything - it recompiles only those files that have changed (i.e., newer than their corresponding class files). This does not pay attention to the fact that the dependency of a class may have changed, and therefore other classes must also be recompiled.
In my current project, I just do ant clean whenever I encounter problems during testing (and, of course, before any production deployment) that deletes all class files. But, as vanza said, there is a depend task, the task of which is to find and remove all classes that depend on your changed classes - run this before your javac task, and you should be good.
source share