[英]AWS Lambda JavaCompiler instance
在AWS Lambda Java 8函數中,是否可以獲取SystemJavaCompiler
的實例? 這是一個片段:
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。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.