You could take a slightly different approach. Instead of trying to redirect the compiler output to file, just check to see if a .class file exists. Of course, this method would require you to first check the directory for an existing .class file and delete it before calling javac.exe.