Re: using JavaCompiler
Peter K wrote:
Roedy Green <see_website@mindprod.com.invalid> wrote in
news:2b07h392tcp3cd22e5a2olqrlf7m1rt2hk@4ax.com:
http://mindprod.com/jgloss/javacexe.html
Thanks, but I am familiar with the command-line options for javac. I was
though under the impression that ToolProvider.getSystemJavaProvider()
ToolProvider.getSystemJavaCompiler();
returned a compiler which might not actually be "javac", and therefore one
could not just assume that the command-line options for "javac" would
necessarily be valid.
Otherwise why not call it ToolProvider.getJavac() ?
But Gordon Beaton seems to also agree with you, that the system compiler is
always "javac", and even if it isn't then any valid java compiler must in
any case use the same command-line options as "javac".
Well, there is no requirement for that IMHO.
However, I suspect that the providers interested in supporting
javax.tools API by theirs compilers will most likely tend to support all
standard options of the Sun's compiler.
If you really don't trust that, you may specify the output directory (as
you had already came to) with a file manager, e.g. that way:
StandardJavaFileManager fileManager
= compiler.getStandardFileManager(null, null, null);
fileManager.setLocation(StandardLocation.CLASS_OUTPUT,
Arrays.asList(outputDir));
compiler.getTask(null, fileManager, null, null, null,
fileManager.getJavaFileObjects(sources)).call();
piotr