The fastest way to check your Java version

Open your command line or terminal and type java -version, then press Enter. The output will show you the exact Java version installed on your computer. This works on Windows, Mac, and Linux.

If you get an error saying "java is not recognized" or "command not found", Java is either not installed or not in your system's PATH — the list of locations your computer searches for programs. The sections below cover both checking your version and fixing the PATH problem if it occurs.

Key Takeaways

  • Run java -version in your command line to see your installed Java version immediately.
  • If the command fails, Java may not be installed, or your system cannot find it because it is not in your PATH.
  • Windows, Mac, and Linux all use the same command, but the steps to open a command line differ slightly by operating system.
  • You may have multiple Java versions installed; check which one your system uses by default with java -version and which ones exist with where java (Windows) or which java (Mac and Linux).

Checking Java version on Windows

Press the Windows key, type cmd, and press Enter to open Command Prompt. Type java -version and press Enter. You will see output like "java version 17.0.1" or "openjdk version 11.0.13" depending on which Java distribution you have.

If you see "java is not recognized as an internal or external command", Java is not in your PATH. You can still find it by searching your computer for java.exe using File Explorer, or by checking the Program Files folder where Java typically installs — usually C:\Program Files\Java or C:\Program Files (x86)\Java.

Checking Java version on Mac

Open Terminal by pressing Command + Space, typing terminal, and pressing Enter. Type java -version and press Enter. The output will show your Java version the same way it does on Windows.

If you see "command not found", Java is not installed or not in your PATH. You can check if Java exists on your Mac by typing which java to see its location, or by opening Finder, pressing Command + Shift + G, and typing /Library/Java/JavaVirtualMachines to see installed Java versions directly in the folder.

Checking Java version on Linux

Open a terminal window (the method varies by Linux distribution — usually right-click the desktop or search for "terminal" in your application menu). Type java -version and press Enter to see your Java version.

If the command fails, type which java to check if Java is installed anywhere on your system. If that returns nothing, Java is not installed. You can also type ls /usr/lib/jvm to see if any Java installations exist in the standard Linux location.

Understanding the version output

The output of java -version tells you three useful things: the Java distribution (Oracle JDK, OpenJDK, Amazon Corretto, etc.), the major version number (8, 11, 17, 21), and the exact patch version. For example, "openjdk version 17.0.5" means you have OpenJDK version 17, patch level 5.

The major version number matters most for compatibility — some programs require Java 11 or newer, while others work with Java 8. The patch level (the number after the second dot) is a security update; newer patches fix bugs and security issues but do not change how the software works.

When you have multiple Java versions installed

It is common to have more than one Java version on your computer, especially if you develop software or use multiple applications. java -version shows you which version runs by default. To see all installed versions, type where java on Windows or which -a java on Mac and Linux.

If you need to use a different Java version for a specific program, you can either change your PATH to point to that version first, or run the program with the full path to a specific Java installation — for example, C:\Program Files\Java\jdk-11.0.13\bin\java.exe -version on Windows. Your program's documentation will tell you if it requires a specific version.

What to do if Java is not installed

If java -version fails and you need Java, you will need to download and install it. The most common options are Oracle JDK (the official version, requires a license for production use), OpenJDK (free and open-source), and Amazon Corretto (free, long-term support). Most developers and applications work with any of these.

Download from the official source for your chosen distribution, run the installer, and follow the on-screen steps. After installation, open a new command line or terminal window and run java -version again to confirm the installation worked. You may need to restart your computer or manually add Java to your PATH if the installer does not do it automatically.

Frequently Asked Questions

Why does my command line say "java is not recognized"?

Java is installed but not in your system PATH, which is the list of folders your computer searches for programs. You can either add Java to your PATH (instructions vary by operating system), or run Java using its full file path instead of just typing java.

Can I have Java 8 and Java 17 installed at the same time?

Yes. You can install multiple versions side by side. java -version shows which one runs by default. To use a different version, either change your PATH to point to it first, or call that version directly by its full path.

What is the difference between JDK and JRE?

JDK (Java Development Kit) includes tools to write and compile Java code. JRE (Java Runtime Environment) only runs Java programs. If you are developing, you need JDK. If you only run Java applications, JRE is enough. java -version works with both.

Does Java version matter for the programs I run?

Sometimes. Some applications require a specific Java version or newer. Check your program's documentation to see what it needs. If you have the wrong version, the program will usually fail to start or show an error message telling you what version it requires.

How do I update Java to a newer version?

Download the newer version from your Java distribution's website and run the installer. It will typically update your existing installation or install alongside it. Run java -version afterward to confirm the update worked.