Home > Software engineering >  How to change java version in Intellij?
How to change java version in Intellij?

Time:11-13

I have a simple java project and I try to change java version in Intellij from java 11 to java 8. It isn't a maven project. I found something on google and it looks easy, but it's not working.

So, I pressed ctrl shift alt s and here I changed jdk11 with jdk1.8:

enter image description here

But now if I run java -version on Intellij terminal I get this in the console:

java version "11.0.14" 2022-01-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.14 8-LTS-263)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.14 8-LTS-263, mixed mode)

It looks that it continue to use java 11. What else should I do? Thank you!

CodePudding user response:

Changing the JDK in IntelliJ UI does not affect its Intellij terminal:

When changing the JDK, we need to remember that this only affects the JDK used by IntelliJ. Therefore, when running the Java project via the command line, it'll still use the JDK specified in the JAVA_HOME environment variable

So when running java on Intellij terminal, you still have to set JAVA_HOME to change java version

  • Related