From the Windows command prompt image you posted, it looks like you are on Windows 7.
The where
command will show the path of files java.exe
and javac.exe
.
Enter the following command at the command prompt:
where java.exe
On my Windows 10 machine with JDK 12.0.1 installed, the output for the above command is:
C:\Program Files\Java\jdk-12.0.1\bin\java.exe
And for javac.exe
...
where javac.exe
C:\Program Files\Java\jdk-12.0.1\bin\java.exe
The folder for javac.exe
must be included in the PATH
environment variable, otherwise the where
command would not find it.
The folder for java.exe
need not be included in PATH
. You may have defined the JAVA_HOME
environment variable, but even that is not required.
In any case, as others have stated, a lower version of the JDK cannot run code that is compiled with a higher version (although the opposite is allowed, i.e. you can compile with a lower version and run it with a higher version).
It would appear that you have more than one JDK (or JRE) version installed. You need to decide which you want to use and modify the PATH
environment variable so that it includes the desired folder containing file javac.exe
.
If you don't require several java versions installed, I recommend simply removing all those that you don't require.