Reputation: 26679
JavaCompiler - How to pass -X options
programmatically to the JavaCompiler class?
Upvotes: 4
Views: 312
Reputation: 132350
The JavaCompiler page you linked to has some nice examples. They invoke the compiler with the following line of code:
compiler.getTask(null, fileManager, null, null, null, compilationUnits1).call();
The fourth argument to the getTask
method is a list of option strings (really Iterable<String>
but a list will be sufficient). So you can do:
compiler.getTask(null, fileManager, null,
Arrays.asList("-Xlint:all"),
null, compilationUnits1).call();
Upvotes: 1
Reputation: 533432
AFAIK The Java Compiler is runs in the current JVM. If you want to set a -X
option you need to set it for your program.
Upvotes: 0