IntelliJ: "invalid source release: 17" error and how to fix it
Codemia Knowledge Hub ·
"Invalid source release: 17" means IntelliJ IDEA is compiling the project with a JDK that does not support the Java version the project asks for, typically an older JDK such as 11 while pom.xml or build.gradle targets 17. Fix it by installing JDK 17, setting it as the Project SDK, setting the module language level to 17, and reimporting the Maven or Gradle project.
Why the error happens
The project is configured for newer Java language features than the JDK in use supports:
- Source release compatibility: Java source releases are tied to JDK versions. JDK 17 supports Java 17 language features. An earlier JDK such as JDK 11 lacks them, so compiling fails with "invalid source release".
- Project SDK: every IntelliJ project has a project SDK, which is the JDK used to compile and run it. If the project specifies a source version the assigned SDK does not support, you get this error.
Two situations usually lead to it:
- Mismatched JDK configuration: the build file (
pom.xmlfor Maven,build.gradlefor Gradle) specifies Java 17, but IntelliJ uses an older JDK. - Project Structure misconfiguration: IntelliJ's Project Structure settings set a module Java version that does not match the SDK version.
Example configuration
A Maven project with this in pom.xml:
fails with "Invalid source release" if IntelliJ is configured to use JDK 11.
How to fix it
- Check that JDK 17 is installed by running this in a terminal:
- Set the Project SDK:
- Go to File > Project Structure > Project.
- Set Project SDK to JDK 17. If JDK 17 is not listed, click "Add SDK" to add it.
- Set the module language level:
- Under File > Project Structure > Modules, select your module.
- In Language level, select the plain 17 level (shown as "17 - Sealed types, always-strict floating-point semantics" in recent IntelliJ versions) to match the source level in your build file. Avoid the "17 (Preview)" entry, which enables preview features and needs
--enable-preview.
- Reimport the project (Maven or Gradle):
- For Maven, click "Reimport" in the Maven tool window.
- For Gradle, do the same in the Gradle tool window to refresh dependencies and configuration.
| Element | Description |
| Error Trigger | Project uses Java 17 features with unsupported JDK |
| Primary Solution | Update Project SDK to a compatible JDK version |
| Configuration Check | Ensure pom.xml or build.gradle aligns with JDK |
| IntelliJ Settings | Verify SDK is set to JDK 17 in Project Structure |
| Tools | Use Project SDK settings, Maven/Gradle reimport |
Avoiding the error in CI and across projects
- CI/CD pipelines: configure the build environment to use the correct JDK version, so automated builds stay consistent and do not hit the same error outside local development.
- Version management: a JDK version manager such as
SDKMAN!makes switching between JDK versions easy. - Regular updates: keep your JDKs and IntelliJ IDEA updated for the latest features and security patches.
- Profile-specific configuration: in multi-profile projects, make sure each profile specifies a compatible JDK version.
Related reading
- Intellij Cannot resolve symbol on import
- IntelliJ does not show 'Class' when we right click and select 'New
- IntelliJ does not terminate Spring Boot applications build with gradle
- IntelliJ Errorjava error release version 5 not supported
- IntelliJ 15, SpringBoot devtools livereload not working
- IntelliJ cannot find any declarations
- intellij idea - Error java invalid source release 1.9
- Intellij IDEA complains cannot resolve spring boot properties but they work fine

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.