Check your Java version from the command line
The fastest way to find out which Java version you have installed is to open a terminal or command prompt and run a single command. Java stores version information that the system can retrieve in seconds, and this method works the same way on Windows, Mac, and Linux.
On Windows, press the Windows key, type cmd, and press Enter to open Command Prompt. On Mac, open Spotlight by pressing Command + Space, type terminal, and press Enter. On Linux, open your terminal process from your applications menu or press Ctrl + Alt + T on most distributions.
Once the terminal or command prompt is open, type this command and press Enter:
java -version
The system will display your Java version in the next line or two. You will see something like "java version 17.0.1" or "openjdk version 11.0.13". If you see an error message saying the command is not recognized, Java is not installed on your computer, or it is not set up so the system can find it.
Key Takeaways
- The command java -version shows your installed Java version in any terminal or command prompt on Windows, Mac, or Linux.
- If the command returns an error, Java is either not installed or not configured in your system path.
- The version number tells you which release you have — Java 8, 11, 17, and 21 are the most common long-term support versions.
- Some computers have multiple Java versions installed, and you may need to check which one your programs are actually using.
Understand what the version number means
Java version numbers follow a pattern that tells you how old the release is and how long it will receive updates. Versions like 8, 11, 17, and 21 are long-term support releases, meaning Oracle (the company that maintains Java) provides security updates for many years. Versions in between, like 12, 13, or 14, receive updates for only six months.
The first number is the major version — Java 17 is the seventeenth major release. The second number after the dot is the minor version, which includes smaller updates and fixes. For example, Java 17.0.5 is Java 17 with five rounds of patches applied. You do not need to memorize this; you mainly need to know whether your version is a long-term support release or a short-term one.
If you see openjdk in your version output instead of just "java", you have the open-source version of Java rather than Oracle's official version. Both work the same way for most purposes, and the version number means the same thing.
Find which Java version your programs are actually using
Some computers have more than one Java version installed. Your system might have Java 11 and Java 17 both present, and different programs might use different versions. The java -version command shows you the default version — the one the system uses when you do not specify otherwise — but not necessarily the one a particular program is running.
To see all Java versions installed on your computer, you can search your system. On Windows, open File Explorer and search for "java.exe" in your C: drive. On Mac, open Finder, press Command + Shift + G, type /Library/Java/JavaVirtualMachines, and press Enter. On Linux, type which java in the terminal to see the path to the default version, or ls /usr/lib/jvm to list all installed versions.
If you need a specific program to use a particular Java version, you will usually find that setting in the program's preferences or configuration files. Some programs let you point them to a Java installation folder; others read an environment variable called JAVA_HOME. Check the program's documentation for instructions.
Update Java if you have an old version
If your version number is Java 8 or older, or if it is a short-term support version that is more than six months old, you may want to update. Older versions receive fewer security patches, and programs increasingly expect newer features that older Java versions do not have.
To update Java, visit the official Oracle Java website or read OpenJDK from the Eclipse Adoptium project, which is free and widely used. Both sites have installers for Windows, Mac, and Linux. read the installer for your operating system, run it, and follow the on-screen steps. The installer will usually detect your existing Java installation and update it in place.
After you install the update, open a new terminal or command prompt window and run java -version again to confirm the new version is now the default. If the old version still appears, you may need to restart your computer or adjust your system path settings.
Troubleshoot when Java is not found
If you run java -version and get an error like "command not found" or "'java' is not recognized as an internal or external command", Java is either not installed or your system cannot find it. The most common cause is that Java is installed but not added to your system path — the list of folders where the system looks for programs.
First, check whether Java is actually installed. On Windows, go to Control Panel, select Programs, and look for Java in the list. On Mac, open System Preferences, click Java if it appears, and check the version there. On Linux, type apt list --installed | grep java (on Ubuntu or Debian) or yum list installed | grep java (on Red Hat or CentOS) to see what is installed.
If Java is installed but the command does not work, you need to add it to your system path. This process differs by operating system and can involve editing environment variables on Windows or adding a line to a configuration file on Mac and Linux. If you are not comfortable with these steps, the simplest solution is to uninstall Java completely and reinstall it using the official installer, which will set up the path automatically.
Check Java version in a program or IDE
If you are using a development environment like Eclipse, IntelliJ IDEA, or Visual Studio Code, you can often check the Java version from within the program itself. In Eclipse, go to Help > About Eclipse > Installation Details and look for the Java Runtime Environment section. In IntelliJ IDEA, go to File > Project Structure and check the Project SDK dropdown. In Visual Studio Code with the Extension Pack for Java installed, open the Command Palette (Ctrl + Shift + P on Windows and Linux, Command + Shift + P on Mac), type "Java: Show Java Version", and press Enter.
These methods show you the Java version that the development environment is using to run itself and to compile your code. This is useful if you are writing Java programs and need to know whether your environment supports the features you want to use.
Frequently Asked Questions
What if I have Java installed but java -version shows a different version than what I see in Control Panel?
Your system path is pointing to a different Java installation than the one listed in your programs. This happens when you have multiple versions installed. You can either change your system path to point to the version you want to use, or uninstall the version you do not need. Check which version your programs actually require before removing anything.
Do I need Java if I am not a programmer?
Many programs you use every day rely on Java running in the background — some banking websites, certain office applications, and many games use Java. You do not need to know about Java versions unless a program tells you to install or update it. If a website or program asks you to install Java, you can do so safely from the official Oracle or OpenJDK websites.
Is OpenJDK the same as Oracle Java?
OpenJDK is the open-source version of Java that Oracle publishes. Both are based on the same code and work the same way. OpenJDK is free and does not require registration. Oracle Java requires you to agree to their license terms. For most purposes, either one works fine.
Why does my program say it needs Java 11 when I have Java 17 installed?
Java is backward compatible, meaning newer versions can run programs written for older versions. If your program needs Java 11 and you have Java 17, it will work. You only have a problem if your program needs a newer version than what you have installed.
Can I have multiple Java versions installed at the same time?
Yes, and many computers do. Different programs can use different versions. Your system path determines which version runs by default when you type java in a terminal, but individual programs can be configured to use a specific version if they need it.