I\'m generating a whole bunch of .java files from an XSD file using XJC. I also need to compile those files to .class files and use them at runtime via reflection.
T
Have you tried looking up existing threads for the same topic ; On-the-fly, in-memory java code compilation for Java 5 and Java 6
for example.
So I finally figured this out...
Apparently you could pass several files to the compiler at once, and this solves the symbol error. What a stupidly simple solution.
public static void compile(String... files) {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
compiler.run(null, null, null, files);
}