import javax.tools.JavaCompiler; import javax.tools.ToolProvider; /** * java的动态编译 * @author Administrator * */ public class Demo04 { public static void main(String[] args) { JavaCompiler compiler=ToolProvider.getSystemJavaCompiler(); int result = compiler.run(null, null, null, "c:\\Test.java"); System.out.println(result==0?"编译成功":"编译失败"); } }
原文地址:https://www.cnblogs.com/qurui1997/p/10609849.html
时间: 2024-10-11 18:17:08