Reads a set of Java™ compilation units (a.k.a. "source files") from the file system, compiles them into a set of "class files" and stores these in the file system. Additional source files are parsed and compiled on demand through the "source path" set of directories.
For example, if the source path comprises the directories "A/B" and "../C", then the source file for class "com.acme.Main" is searched in
- A/B/com/acme/Main.java
- ../C/com/acme/Main.java
Notice that it does make a difference whether you pass multiple source files to {@link #compile(File[])} or if you invoke{@link #compile(File[])} multiply: In the former case, the sourcefiles may contain arbitrary references among each other (even circular ones). In the latter case, only the source files on the source path may contain circular references, not the
sourceFiles
.
This method must be called exactly once after object construction.
Compile errors are reported as described at {@link #setCompileErrorHandler(UnitCompiler.ErrorHandler)}.
@param sourceFiles Contain the compilation units to compile
@return true
for backwards compatibility (return value can safely be ignored)
@throws CompileException Fatal compilation error, or the {@link CompileException} thrown be the installed compileerror handler
@throws IOException Occurred when reading from the sourceFiles