Search code examples
javaincompatibilityunsupported-class-version

Not able to get java version in windows


When I run on console javac -version, I get the version number as 11.0.2, but when I run java -version I get the following error:

Error: opening registry key 'Software\JavaSoft\Java Runtime Environment'
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

What should I do about this?

Which version of JRE do I need to install for JDK 11.0.2,so that I won't get any compatibility issues which executing java code?


Solution

  • Check path. To make sure that Windows can find the Java compiler and interpreter:

    Select Start -> Computer -> System Properties -> Advanced system settings -> Environment Variables -> System variables -> PATH.

    Prepend C:\Program Files\Java\jdk1.x.x\bin to the beginning of the PATH variable.