Does javax.tools depend on the JDK?

后端 未结 1 1045
暖寄归人
暖寄归人 2021-01-02 19:42

I want to use JavaCompiler to dynamically create some classes.

I found the source code of the javax.tools package, but there is no impleme

相关标签:
1条回答
  • 2021-01-02 20:14

    JRE's need to include the interfaces, and classes in that package, but do not need to provide implementations.

    Sun's JRE doesn't, and returns null from calling ToolProvider.getSystemJavaCompiler().

    This other question addresses java 5.

    Here's a blog post by Morten Nobel-Jørgensen on how to use eclipse's compiler as an implementation of javax.tools.JavaCompiler.

    JavaCompiler javac = new EclipseCompiler();
    
    0 讨论(0)
提交回复
热议问题