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的資源節省中受益。
也許沒有SDK,JRE只有 – Antoniossss
我剛剛意識到這一點:( – hisdrewness
@Antoniossss提交您的評論作爲答案,所以我可以接受它 – hisdrewness