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.

3
  • 2
    Maybe there is no SDK, JRE only Commented Dec 18, 2017 at 6:25
  • I just realized this as well :( Commented Dec 18, 2017 at 6:29
  • @Antoniossss submit your comment as an answer so I can accept it Commented Dec 22, 2017 at 17:06

1 Answer 1

1

Maybe there is no SDK, JRE only.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.