How to compile all files in directory to *.class files?
Yet another way using "find" on UNIX is described here:
http://stas-blogspot.blogspot.com/2010/01/compile-recursively-with-javac.html
The following two commands will compile all .java files contained within the directory ./src
and its subdirectories:
find ./src -name *.java > sources_list.txt
javac -classpath "${CLASSPATH}" @sources_list.txt
First, find
generates sources_list.txt
, a file that contains the paths to the Java source files. Next, javac
compiles all these sources using the syntax @sources_list.txt
.