0

I encountered a problem with the Java version I am using for running some .jar files in my command prompt (Unsupported major.minor version 52.0), I checked the version used for compiling and running in IntelliJ IDEA (JDK 11.0.9) so I supposed It came from the version I am using in my prompt.

So what I did was changing the JAVA_HOME to “C:\Program Files\Java\jdk-11.0.9” and add it to both user and system variables (“C:\Program Files\Java\jdk-11.0.9\bin”).

To check if this was done correctly I typed :

javac – version : javac 11.0.9 (correct)

But when I checked

java –version 

It gives me the following error: “Error could not open C:\Program Files\Java\jre7\lib\amd64\jvm.cfg" which is totally normal because I just removed this directory but I expected my prompt to use the new path..

Can anyone help ?

3
  • Check your PATH variable as well. The command line doesn't care about JAVA_HOME, per se Commented Mar 24, 2021 at 17:20
  • I know the Oracle installer adds a java.exe in windows\system32 that looks at the registry for which instance it should delegate to. To override this you need to get the JAVA_HOME\bin in front of windows\system32. Adding it to the user environment PATH doesn't work, because that's appended to the system PATH. You have to add it to the system environment PATH, then move it up so it's before window\system32. Commented Mar 24, 2021 at 20:37
  • Thank you for all your responses, the problem came from the "windows\system32" entry which was before my new entry. I thought I had tested it... Commented Mar 25, 2021 at 8:13

1 Answer 1

1

Concur with federico. You need to have PATH point to the new JDK/JRE to complete the replacement. Also if both entries are in the PATH it will choose the first one so you might just need to remove the old one.

You can modify path in windows by clicking window button and typing ENV - An option that says "Edit the System and Environment Variables" should pop up. Click it and look in the Environment Variables section.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.