[英]AWS Lambda JavaCompiler instance
在AWS Lambda Java 8函数中,是否可以获取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的资源节省中受益。
也许没有SDK,仅JRE。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.