How do I use JDK6 ToolProvider and JavaCompiler with the context classloader?
问题 My usage case is compiling generated source files from a java program using the ToolProvider and JavaCompiler classes provided in JDK 6. The source files contain references to classes in the context classloader (it runs in a J2EE container), but not in the system classloader. My understanding is that by default the ToolProvider will create the JavaCompiler instance with the system classloader. Is there a way to specify a classloader for JavaCompiler to use? I tried this approach, modified