10.2.2. Using Compilation Tasks

You can have even more control over the compilation process with a CompilationTask object. In particular, you can

• Control the source of program code—for example, by providing code in a string builder instead of a file.

• Control the placement of class files—for example, by storing them in a database.

• Listen to error and warning messages as they occur during compilation.

• Run the compiler in the background.

The location of source and class files is controlled by a JavaFileManager. It is responsible for determining JavaFileObject instances for source and class files. A JavaFileObject can correspond to a disk file, or it can provide another mechanism for reading and writing its contents.

To listen to error messages, ...

Get Core Java® Volume II—Advanced Features, Ninth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.