Intellij, target JRE vesion doesn't match project jdk version
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Understanding the “Target JRE Version Doesn’t Match Project JDK Version” Issue in IntelliJ
When developing Java applications in IntelliJ IDEA, one common issue developers might encounter is the message: "Target JRE version doesn't match project JDK version." This warning or error can appear in various areas of the IDE, such as in build configurations or when running applications. Understanding and resolving this can ensure better compatibility and runtime performance for Java applications.
Background & Context
Java Development Kit (JDK) and Java Runtime Environment (JRE) are essential components of Java development. The JDK includes tools for developing and debugging Java applications; the JRE, a subset of the JDK, provides libraries, Java Virtual Machine (JVM), and components to run Java applications.
Problem Insight
The issue arises when there is a mismatch between the JDK version configured for the project and the JRE version targeted by the application's build or runtime configuration. If a project is compiled with one version and run with another, it might lead to compatibility problems, especially when using features introduced in newer versions of Java.
Analyzing the Issue
Symptoms:
- Compilation errors indicating class or method is undefined.
- Runtime errors due to unsupported features.
- Warnings within the IntelliJ IDEA that notify about version discrepancies.
Technical Explanation with Examples
Consider a scenario where you have set your project’s JDK to version 17 but your build configuration is targeted to JRE version 11. This can create issues if your code uses features not present in JRE 11.
Example
- Align your project's JDK with the JRE target version. If you're using JDK 17 to compile, ensure the target JRE is also 17.
- Navigate to `File > Project Structure > Project`. Ensure the SDK used in the "Project SDK" field is consistent with the intended target version.
- Under `Modules`, verify each module's language level aligns with the project’s SDK.
- Maven/Gradle: If using build tools, ensure your `pom.xml` or `build.gradle` aligns with the desired Java version:
- Use IntelliJ's version control and quick fixes to ensure your project's JDK and target bytecode versions align.
- Regularly update IntelliJ to leverage improvements in version management and compatibility checking.
Related reading
- intercepting session set attribute call
- Interceptor not getting initialized and invoked with SpringBoot
- Interface naming in Java
- Interface vs Abstract Class (general OO)
- Interoperating with Django/Celery From Java
- Interrupt a sleeping Thread
- Intersection and union of ArrayLists in Java
- ''Invalid bean definition'' when migrating Spring Boot 2.0.6 to 2.1.0 with EvaluationContextExtensionSupport and custom PermissionEvaluator

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.