I'm trying to compile many files using the Compiler API.
Say I have a directory structure
.../program +/org +/foo |+ Main.java +/bar + Tools.java
Is there any way to discover all the Java files and make it compiler everything without resorting to recursing into all the directories and finding all the *.java files?
EDIT: What I'm trying to do is compile all the classes that I get in some directory tree. These classes are independent of each other. Then I load the classes and instantiate some objects of these classes and call methods. None of the classes need to have main.
The
javax.tools.JavaFileManager
class has alist()
method that should do the trick:Use the
recurse
parameter to include "subpackages" and then just iterate over the returnedJavaFileObject
.