javac TestProgram1.java TestProgram2.java TestProgram3.java
You can use a wildcard to compile all the files in a folder, like this:
javac *.java
If you need to compile a lot of files at the same time but don’t want to use a wildcard (perhaps you want to compile a large number of files but not all the files in a folder), you can create an argument file, which lists the files to compile. In the argument file, you can type as many filenames as you want, using spaces or line breaks to separate them. Here’s an argument file named TestPrograms that lists three files to compile:
TestProgram1.java
TestProgram2.java
TestProgram3.java
You can compile all the programs in this file by using an @ character, followed by the name of the argument file on the javac command line, like this:
javac @TestPrograms
-cp and -classpath
Specifies where to find user class files. Use this option if your program makes use of class files that you’ve stored in a separate folder.