AWS Lambda JavaCompiler instance

时间:2017-12-18 05:23:28

标签: java amazon-web-services aws-lambda aws-sdk aws-sdk-java-2.0

In an AWS Lambda Java 8 Function, is it possible to get an instance of 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. This works great locally. I was hoping to avoid deploying an EC2 instance to benefit from the resource savings of Lambda.

1 个答案:

答案 0 :(得分:1)

也许没有SDK,仅限JRE。