How to know the jdk version on my machine?

you might need to add path in environment variables which you can find in Control Panel open the Jdk where you installed and add until /bin in the path in environment variables.

Add until /bin in path variable in System Variables which is residing in Environment Variables.

Then do java -version which might show up.

If still problem persists, try restarting your pc and see.


To get your jdk location in Windows, run this at a command prompt:

where java

This lists any and all locations of java.exe, including from your JAVA_HOME. For example, the 3rd line here reflects my JAVA_HOME location, where I'm pointing to JDK 8:

C:\Users\me> where java
C:\Program Files\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files\Java\jdk1.8.0_202\bin\java.exe

Note for comparison that java -version does not reflect my JAVA_HOME location and in fact shows java version 11 instead of 8:

C:\Users\me> java -version
java version "11.0.15" 2022-04-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.15+8-LTS-149)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.15+8-LTS-149, mixed mode)

This is confusing because my Java compiles (e.g., via mvn) use JDK 8 since that's what my JAVA_HOME is pointing to.

Determining the difference between the JRE and JDK you're running has never been straightforward. Seems like java -version used to be a way to do this, but no longer.

Adding to the complexity, you can also supposedly get your Java version info from Control Panel > Programs > Java > About. For me, that shows Version 8. That's despite java -version showing version 11.0.15. And it doesn't change even if I point my JAVA_HOME to JDK 11.


On Windows 10, this required mapping the environment variable for JAVA_HOME to the JDK installation directory. Use these steps:

  1. Run the installer for the JDK. (available for windows here: https://www.oracle.com/java/technologies/downloads/#jdk17-windows)

  2. windows key -> Environment Variables, select the only result

  3. In the System Properties window that opened, select Environment Variables enter image description here

  4. Select new button under the User variables section

  5. Variable name: JAVA_HOME, Variable Value: <The JDK filepath from step 0>

  6. ok all open menus

  7. Close any open cmd prompt windows

  8. open a new cmd window and type echo %JAVA_HOME% It should print the installation path for the JDK.


You need to update your Windows path to include your %JAVA_HOME%\bin directory. %JAVA_HOME% is the directory that you installed Java into and is also an environment variable that you need to configure for command line execution of your applications. You can edit both of these in the Windows control panel and you should restart.

When you run java -version you will see the internal version number. This is explained here: https://en.wikipedia.org/wiki/Java_version_history.

Basically, you can ignore the 1. when reading version number. The _xxx is a reference to the most recent patch or build release.

Tags:

Java

Java 8