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.
答案 0 :(得分:1)
也许没有SDK,仅限JRE。