在AWS Lambda Java8函数中,可以获得SystemJavaCompiler的实例吗?下面是一段代码:
final File root = new File("/tmp");
final File sourceFile = new File(root, type.getSourceFilename());
sourceFile.getParentFile().mkdirs();
Files.write(sourceFile.toPath(), templateString.getBytes(StandardCharsets.UTF_8));
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
compiler.run(null, null, null, sourceFile.getPath());我试图在Lambda中动态编译源代码,而ToolProvider.getSystemJavaCompiler()抛出了一个NullPointerException。这在本地运行得很好。我希望避免部署EC2实例,以从Lambda的资源节约中受益。
发布于 2017-12-23 04:14:03
也许没有SDK,只有JRE。
https://stackoverflow.com/questions/47862541
复制相似问题