Target JRE version does not match project JDK version (null)

Answered

Hi,

 

Whenever i try to run my project i get the following warning:

My project settings seem to be configured correctly:

Does anyone have an idea what's wrong with my environment?

 

Thanks,

Nadav

 

1
23 comments

Hello,

Please check that JDK is also set for modules ("Project Structure | Modules - Dependencies")

 

0

Hi,

 

It is set on all my modules:

0

Hi,

 

Is there anything else I can check?

 

Thanks,

Nadav

0

Could you please attach screenshot from "Settings | Build... | Compiler | Java Compiler"?

0

Does the issue occur for any project or only for this specific one?

Please try the latest version from http://www.jetbrains.com/idea/download/index.html. In case the issue persists, please file a bug at https://youtrack.jetbrains.com/issues/IDEA and attach the project files there (.idea directory and .iml files).

You can also try to remove the JDK configuration and add it again from scratch in the Project Structure | SDKs dialog.

Ensure that the correct JDK is specified for every module (your screenshot confirms it only for one module).

0

Hi,

 

I tried the new version and the latest SDK with the same result.

However I noticed that when I select "Use JAVA_HOME" in the maven runner settings I get the error message.

If I select any other option the issue is resolved.

Thanks,

Nadav

0

I had similar issues with my gradle debugging but they went away when gave the two JRE's called "1.8" unique names.  I could then select the JRE that matched the Gradle JRE.

2

Wian's comment solved the issue for me. It's not helpful that the JDK / language level value being used needs to be changed in many places: Project, Modules, Gradle/Maven, Java compiler, on and on. For example, when updating from 1.8.0_131 to 1.8.0_161, it would be convenient if there was an option at the project level to declare: "Change all JDKs referenced in this project to the selected JDK 1.8.0_161", then let IDEA go about leveling them all up.

I recognize there are some complexities; i.e. one module needs to stay at JDK 1.7, etc., but that's already accommodated by the use Project JDK option on the module.

Alternatively, even a report in one place that showed all the various JDKs / JREs in use with a link to the settings page to change the value would be more helpful than some oblique toast message telling us some JDK for some unspecified context is out of sync with some JRE for some other unspecified context.

1

There is an option too on the running configuration:

2

Thanks, Peter, your answer solved my problem.

0

Since I've updated Intellij to 2021.3, I'm getting a similar (except the "null") error message:

Target JRE version (1.8.0_312) does not match project JDK version (java version "1.8.0_121"), will use sources from JDK: 1.8-corretto

 

Another difference is that I'm building with ant. And unfortunately, I could not find where I have to confugure this for ant other than the "Build File properties" of the build.xml. But there, I already have selected "Project SDK (OpenJDK_8)".

 

I have two 1.8 JDK's installed: OpenJDK and Corretto. I need the former one for my web projects (that will run on a target machine having only OpenJDK-headless installed) ant the latter one for some JavaFX projects.

 

I haven't set JAVA_HOME, JRE_HOME and any other

 

0

Check the run configuration JRE version.

0

In which tab of the run configuration should I find it ? It's a "Tomcat Server" type run configuration.

0

Looks like it's even a bit stranger ... I've just checked my installed java versions. None of my installed 1.8 JDKs is "1.8.0_121" as reported by Intellij to be the project SDK.

$ /usr/lib/jvm/java-8-openjdk/bin/java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-b10)
OpenJDK 64-Bit Server VM (build 25.312-b10, mixed mode)

$ /usr/lib/jvm/java-8-amazon-corretto/bin/java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment Corretto-8.312.07.1 (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM Corretto-8.312.07.1 (build 25.312-b07, mixed mode)

$ ls -l /usr/lib/jvm/
total 24
lrwxrwxrwx 1 root root 15 Okt 14 16:55 default -> java-17-openjdk/
lrwxrwxrwx 1 root root 15 Okt 14 16:55 default-runtime -> java-17-openjdk/
drwxr-xr-x 9 root root 4096 Okt 28 10:20 java-11-amazon-corretto/
drwxr-xr-x 7 root root 4096 Nov 13 20:55 java-11-openjdk/
drwxr-xr-x 5 root root 4096 Jul 16 2021 java-15-openjdk/
drwxr-xr-x 7 root root 4096 Nov 13 20:55 java-17-openjdk/
drwxr-xr-x 7 root root 4096 Dez 22 11:08 java-8-amazon-corretto/
drwxr-xr-x 6 root root 4096 Dez 29 06:17 java-8-openjdk/

 

0

See https://stackoverflow.com/a/12900859/104891 for the relevant screenshots, check all the JDK versions defined in the dependencies of the modules and the JDK version specified for the project. Delete JDK configurations for the IDE and add a new one.

0

I've also checked the "JRE" option in the run configuration. It was empty. Now I've selected "OpenJDK_8". But the error message did not go away. Interestingly, Intellij says my OpenJDK is "1.8.0_121" but it isn't.

0

Delete it from Project Structure | SDKs.

0

Solved ... I had to delete and re-add the JDK (in "Project Structure" -> "SDKs"

0

I've got the same problem, I specify my project/module/gradle/javac/run-config to all use JDK 17, but intellij still insists on executing using my system JDK (11) instead of the one I've specified.  What have I missed?

 





0

Paul Galbraith Please contact support at https://intellij-support.jetbrains.com/hc/requests/new. Attach the logs using Help | Collect Logs and Diagnostic Data and the project metadata files (.idea directory zipped + *.iml files). Please also share options/jdk.table.xml from the Configuration directory: https://www.jetbrains.com/help/idea/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-directory.

0

Thanks for the quick response, Serge.  I found the problem, in the run configuration file there was an ALTERNATIVE_JRE_PATH option (which doesn't reflect anywhere in the UI that I could see) that specified the problem JDK.  Deleting that entry solved my problem.

0

Please sign in to leave a comment.