-1

I try to understand why do I have Java 11 in Intellij. When I run the java -version in Intellij terminal I get this response:

openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+12-b304.10)
OpenJDK 64-Bit Server VM (build 11.0.3+12-b304.10, mixed mode, sharing)

When I run the same command from Windows command prompt I get this:

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

I really don't understand why I have Java 11 in Intellij terminal because I have these Project settings:

enter image description here

Modules:

enter image description here

Java Compiler:

enter image description here

And in the pom.xml:

<properties>
    <java.version>1.8</java.version>
</properties>

So why do I have Java 11? I want to use Java 8. Any feedback will be appreciated.

elvis
  • 956
  • 9
  • 33
  • 56
  • 2
    In your inteliJ terminal, can you print the value of the `%PATH%` environment variable. Also do the same in windows cmd, then update your post to reflect the result – smac89 Dec 03 '19 at 20:28
  • 3
    See https://stackoverflow.com/a/58125957/104891 – CrazyCoder Dec 03 '19 at 20:31

1 Answers1

3

The shell running in IDEA inherits its environment from IDEA. IDEA is itself a Java program, so whatever script or stub program started its JVM probably set the PATH so that it picks up the version 11 JDK that was installed with IDEA. When you do java -version in the IDEA shell, you get IDEA's version. But outside of IDEA, the version you get is determined by the PATH you set up in your Windows environment.

Willis Blackburn
  • 8,068
  • 19
  • 36