Started Java development on a Windows system that is not owned by you or just want to know what version of Java is installed on your system, here are the commands to follow. After installing the JDK which is important to develop Java applications, the command prompt or Powershell is the easiest and straightforward way to know about your Java envrionment, here in this article we learn how to do that.
Using the Java Command
The Java command line tool will be available once you successfully install the JDK on your system. However, if you have not done that already then learn the single command to install the latest version of OpenJDK on Windows 10 or 11 systems.
1. Open CMD or PowerShell:
You can use PowerShell, however here we are using the Command prompt to check the version of the installed Java. So, either press Windows Key + R to open the Run dialog and type cmd to open command prompt or click on the Windows start button and search CMD, as it appears click to run it.
2. Identify Java version on Windows 11 or 10
We are assuming that you already have the JDK installed on your Windows system, hence run the given command and you will get the output revealing the currently installed version of Java on your Windows system.
In the Command Prompt, type the following command and press Enter key.
3. View the Version Information:
Once you execute the command given in the previous step, you will have the output something like given below:
Example output: We have version 11 of Java. the same is shown in the given result:
openjdk version "11.0.15" 2022-04-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.15+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+9-LTS, mixed mode)
The version information produced by the command of this step will also include the build date, Runtime Environment, and Java server VM details apart from the core Java version.
Using the Javac Command (Optional)
Another way to check the installed version of Java not only in Windows but also on other operating systems is by looking at the version of Java Complier or Javac. So, in the command prompt instead of using the “java” command, you can use the given one as well:
View the Version Information:
The output version of Javac will be the version of JDK installed on your Windows PC or laptop.
Note: If you have multiple JDK versions installed, make sure the version you want to use is set in your system’s PATH environment variable.