How to specify JVM to gradle when using AWS lambda

Tags: ,

I’m using AWS Lambda with Java and I’m running into this issue. Can someone help?

“gradlew is using a JVM with major version 14 which is newer than 11 that is supported by AWS Lambda. The compiled function code may not run in AWS Lambda unless the project has been configured to be compatible with Java 11 using ‘targetCompatibility’ in Gradle”

I tried changing my JDK to

And I tried following the instructions here but it was no help:


Adding the following to your build.gradle should resolve this:

plugins {
    id("java-library") // or id("application")

java {
    toolchain {

Source: stackoverflow