How to compile Java files to external directory
javac -d EXTERNAL_DIR SRC_FILE
Here are some examples,
javac -d D:\classes MyClass.java
javac -d D:\classes E:\java\MyClass.java
-drepresents a directory and that you'll have to specify a directory to store the class files but not a file. Also, the directory where the class files should be stored must exist. The source file of course must exist first of all.
You can see javac -help for more options.