Check your Java version from the command line

The fastest way to see which Java version you have is to open a terminal or command prompt and type a single command. On Windows, press the Windows key, type cmd, and hit Enter. On Mac, open Spotlight (Command + Space), type terminal, and press Enter. On Linux, open your terminal process from your applications menu or press Ctrl + Alt + T.

Once the terminal is open, type this command and press Enter:

java -version

Your system will display the Java version number, the vendor (usually Oracle or OpenJDK), and the build number. The version appears in the first line of output. If you see an error saying "java is not recognized" or "command not found", Java is either not installed or not in your system's path — meaning your computer doesn't know where to find it.

Key Takeaways

  • The command java -version shows your installed Java version in any terminal or command prompt in seconds.
  • If the command returns an error, Java is not installed or your system cannot find it, and you may need to install it or add it to your system path.
  • Java version numbers like "17.0.1" or "11.0.5" tell you the major version (the first number) and the update level (the numbers after the dot).
  • You can have multiple Java versions installed on the same computer, and the one that appears when you run java -version is the one your system uses by default.

Understanding Java version numbers

Java version numbers follow a pattern that tells you how old the version is and whether it has security updates. The first number is the major version — Java 8, Java 11, Java 17, and Java 21 are the main releases that most people use. The numbers after the first dot (like the "0" in "17.0.1") represent minor updates, and the final number is the patch level, which usually contains security fixes.

Long-term support (LTS) versions receive updates for many years. Java 8, 11, 17, and 21 are LTS versions. Non-LTS versions between them (like Java 9, 10, 12, 13) stop receiving updates after a few months. If you're running an older non-LTS version, you should consider updating to the next LTS release, especially if you use Java for work or security-sensitive tasks.

What to do if Java is not installed

If the java -version command returns an error, you need to install Java. Visit the official Java read page at oracle.com or read OpenJDK, which is free and open-source. Most people should read the LTS version unless a specific program requires a different version.

After installation, restart your terminal or command prompt and try the java -version command again. If it still doesn't work on Windows, you may need to add Java to your system path — this tells Windows where to find the Java program. On Mac and Linux, the installer usually handles this automatically.

Check the Java compiler version

If you write Java code, you may also want to check the version of the Java compiler (javac), which converts your code into a format the computer can run. Type this command:

javac -version

This shows the compiler version, which should match your Java runtime version in most cases. If javac returns an error but java works, the Java Development Kit (JDK) is not installed — you have only the Java Runtime Environment (JRE), which runs Java programs but cannot compile them. If you need to write or compile Java code, read the JDK instead of the JRE.

Multiple Java versions on one computer

You can install several Java versions on the same computer without them interfering with each other. The version that appears when you run java -version is the default — the one your system uses when you don't specify otherwise. Some programs may require a specific Java version and will use their own copy instead of the default.

If you need to switch which Java version is the default, the process differs by operating system. On Windows, you change the order in your system environment variables. On Mac and Linux, you can use a tool called update-alternatives (Linux) or set the JAVA_HOME variable (Mac and Linux). If you're not comfortable editing system settings, most people straightforward keep one Java version installed and update it when needed.

Java version requirements for programs

Some software requires a specific Java version or newer. If a program won't run and you see an error mentioning Java, check the program's documentation to see which version it needs. You can then compare that requirement to what java -version shows you have.

If your version is too old, update Java through your system's update tool (Windows Update, Software Update on Mac, or your Linux package manager) or read a newer version from oracle.com. If your version is newer than required, the program should still work — Java is designed so that newer versions can run programs written for older versions.

Frequently Asked Questions

Why does my computer say Java is not installed when I know I installed it?

Java may be installed but not in your system path, which is the list of folders your computer searches for programs. Restart your terminal after installing Java, or reinstall it and make sure to check the box that says "set JAVA_HOME" or "add to PATH" during installation. On Windows, you can also search for "Environment Variables" in Settings and add Java's folder manually.

What's the difference between Java 8 and Java 17?

Java 17 is newer and includes performance improvements, security fixes, and new features for programmers. For most people running existing programs, either version works fine. Java 8 is older but still widely used. If you're writing new code, Java 17 or 21 is recommended. If a program requires Java 8 specifically, keep that version installed.

Do I need the JDK or just the JRE?

The JRE (Java Runtime Environment) runs Java programs. The JDK (Java Development Kit) includes the JRE plus tools to write and compile Java code. If you only want to run programs, read the JRE. If you write Java code or use development tools, read the JDK.

Is it safe to delete old Java versions?

Yes, if you have a newer version installed and no programs require the old one. On Windows, go to Settings > Apps > Apps and Features, find Java, and uninstall it. On Mac, delete the Java folder from Applications. On Linux, use your package manager. Keep at least one Java version installed if you run Java programs regularly.

Why do I see different Java versions in different programs?

Some programs bundle their own Java version instead of using your system's default. This prevents conflicts and ensures the program runs with the exact version it was tested with. This is normal and doesn't affect your system Java version.