简体   繁体   English

AWS Lambda JavaCompiler实例

[英]AWS Lambda JavaCompiler instance

In an AWS Lambda Java 8 Function, is it possible to get an instance of SystemJavaCompiler ? 在AWS Lambda Java 8函数中,是否可以获取SystemJavaCompiler的实例? Here's a snippet: 这是一个片段:

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());

I'm attempting to dynamically compile source code in a Lambda and ToolProvider.getSystemJavaCompiler() throws a NullPointerException . 我试图在Lambda中动态编译源代码,并且ToolProvider.getSystemJavaCompiler()抛出NullPointerException This works great locally. 这在本地效果很好。 I was hoping to avoid deploying an EC2 instance to benefit from the resource savings of Lambda. 我希望避免部署EC2实例,以从Lambda的资源节省中受益。

也许没有SDK,仅JRE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM