find . -name '*.class' -printf '%h\n' | sort -u
From man find:
-printfformat
%hLeading directories of file’s name (all but the last element). If the file name contains no slashes (since it is in the current directory) the%hspecifier expands to".".