Posted On: Nov 17, 2023

AWS Lambda now supports creating serverless applications using Java 21. This runtime is based on the latest long-term support release of AWS Corretto, Amazon’s distribution of OpenJDK. Developers can use Java 21 as both a managed runtime and a container base image, and AWS will automatically apply updates to the managed runtime and base image as they become available.

The Lambda Java 21 runtime is built on the new Amazon Linux 2023 runtime, which provides a significantly smaller deployment footprint than earlier Amazon Linux 2-based runtimes, updated versions of common libraries such as glibc, and a new package manager. It supports AWS Lambda Snap Start (in supported Regions) for fast cold starts. Powertools for AWS Lambda (Java), a developer toolkit to implement serverless best practices and increase developer velocity, also supports Java 21.

The Java 21 runtime is available in all Regions where Lambda is available, except for China and GovCloud Regions.

You can use the full range of AWS deployment tools, including the Lambda console, AWS CLI, AWS Serverless Application Model (AWS SAM), CDK, and AWS CloudFormation to deploy and manage serverless applications written in Java 21. To migrate existing Lambda functions running earlier Java versions, review your code for compatibility with Java 21 and then update the function runtime to Java 21 when redeploying you function. You can also use the AWS-provided Java 21 base image to build and deploy Java 21 functions using containers. For more information about AWS Lambda, visit our product page.