0

在AWS Lambda Java 8功能中,是否可以获得SystemJavaCompiler的实例?这里有一个片段:AWS Lambda JavaCompiler实例

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的资源节省中受益。

+2

也许没有SDK,JRE只有 – Antoniossss

+0

我刚刚意识到这一点:( – hisdrewness

+0

@Antoniossss提交您的评论作为答案,所以我可以接受它 – hisdrewness

回答