JCI 是一个封装了 Java 编译器的类库。
示例代码:
JavaCompiler compiler = new JavaCompilerFactory().createCompiler("eclipse");
CompilationResult result = compiler.compile(sources, new FileResourceReader(sourceDir), new FileResourceStore(targetDir));
System.out.println( result.getErrors().length + " errors");
System.out.println( result.getWarnings().length + " warnings");
支持的编译器包括:
- eclipse
- janino
- groovy
- javac
- rhino
Apache Commons JCI 1.1 发布了,改进记录:
Changes in this version:
o Updated the API to use generics
o JaninoJavaCompiler is now compatible with Janino 2.6 (JCI-69)
o EclipseJavaCompiler is now compatible with the Eclipse JDT compiler 4.2.2
o Dropped the javac compiler since it only worked with Java 5 (JCI-73)
o Improved the thread safety of FilesystemAlterationMonitor (JCI-74)
o The FilesystemAlterationMonitor thread is now a daemon thread (JCI-65)
o The Eclipse compiler now supports source/target 1.7
Fixed bugs:
o Fixed a NPE in FilesystemAlterationMonitor when the directory is not
readable (JCI-68)
o Compiling classes with cross imports using Janino no longer causes a
stack overflow (JCI-53)
o FilesystemAlterationMonitor no longer throws a NPE when calling stop()
before start() (JCI-62)
o EclipseJavaCompiler properly closes the InputStreams (JCI-58)
o Eclipse compiler settings are no longer ignored (JCI-50, JCI-51)
o Fixed an issue preventing the Eclipse compiler from loading resources
from the ResourceStore (JCI-56)
Commons JCI 的下载地址:请点这里
