Is it possible to programmatically compile java source code in memory only?

前端 未结 3 480
情话喂你
情话喂你 2020-11-30 00:43

I have found many references explaining how to programmatically compile a Java class using the JavaCompiler class:

JavaCompiler compiler = ToolP         


        
3条回答
  •  情歌与酒
    2020-11-30 01:28

    JavaDocs are your friend:

    http://download.oracle.com/javase/6/docs/api/javax/tools/JavaCompiler.html

    Look at the last section that refers to the SimpleJavaFileObject; it shows you how to use it in conjunction with code that is stored in a String

提交回复
热议问题