have you tryed

Code:
$javac ClassToCompile.java>file.txt
yet?