目次
- 1 1. Introduction
- 2 2. How to Check Your Java Version
- 3 3. How to Install Java
- 4 4. How to Update Java
- 5 5. Common Issues and Troubleshooting
- 5.1 5.1 When “java is not recognized as an internal or external command” Appears While Checking Versions
- 5.2 5.2 Multiple Java Versions Coexist and an Unintended Version Is Used
- 5.3 5.3 Build Errors Occur in IDEs like Eclipse (Example: “Compiler compliance level does not match”)
- 5.4 5.4 Old Versions Remain After Updating Java
- 5.5 5.5 “Unsupported major.minor version” Appears in Java Web Apps
- 6 6. FAQ (Frequently Asked Questions)
- 6.1 Q1. What is the difference between JRE and JDK?
- 6.2 Q2. What does the Java version number mean?
- 6.3 Q3. Is it okay to have multiple Java versions installed?
- 6.4 Q4. Should I uninstall older Java versions?
- 6.5 Q5. How do I switch between Java versions?
- 6.6 Q6. I frequently receive Java update notifications. Is it safe to ignore them?
- 7 7. Summary
1. Introduction
Why Java Version Management Matters
Java is a programming language widely used in various fields of software development, such as web applications, mobile apps, and enterprise systems. Its evolution has been rapid, and each version introduces new features and specification changes. For example, Java 8 introduced lambda expressions and the Stream API, while from Java 11 onward, some modules were deprecated, affecting compatibility with runtimes and libraries. To properly handle these changes, it is essential to always know “which Java version is currently used” in your own development environment. In addition, in enterprises and development teams, specific Java versions are often designated for security reasons and long-term support (LTS) policies. Therefore, if the version in use is too old, it may involve risks due to end-of-support.Purpose of This Article and Who It Is For
This article provides a comprehensive explanation of how to check your Java version, install Java, update it, and troubleshoot issues. This article is intended for:- Beginners who want to start developing with Java
- Intermediate users who want to check the version currently in use
- Practitioners who are experiencing issues with environment setup or updates
2. How to Check Your Java Version
2.1 Checking Java Version via Command Line
Using the java -version Command
The most basic and reliable way is to use the command line to check the Java version. This works regardless of the operating system. Common Procedure:- Open the Terminal (macOS/Linux) or Command Prompt (Windows).
- Enter and execute the following command:
java -versionExample Output:java version "17.0.2" 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)From this result, you can see that the version of the “Java Runtime Environment (JRE)” is 17.Checking the JDK Version with javac -version
It is also useful to check the version of javac, the Java compiler, to confirm that the JDK is correctly installed.javac -versionExample Output:javac 17.0.2Checking the Location of the Java Executable
If multiple versions are installed, it is important to check which executable is being used.- Windows:
where java- macOS/Linux:
which javaBy checking the output path, you can identify where Java is installed.2.2 Checking via GUI (Windows)
If you are not comfortable with command-line operations, you can also check the Java version from Windows GUI.Using the Java Control Panel
- Open the Start menu, type “Java,” and open “Configure Java.”
- Click the “Java” tab and select “View.”
- A list of installed Java versions will appear.
2.3 Checking via GUI (macOS)
You can also check the Java version via GUI on macOS.Checking from System Settings
- From the Apple menu, open “System Settings” > “Java.”
- The Java Control Panel will launch.
- Select the “Java” tab and click “View.”
2.4 Checking Java Version with Eclipse
If you are using Eclipse as your development environment, it is important to check the Java version set per project. Steps:- Launch Eclipse and right-click the target project.
- Go to “Properties” > “Java Compiler.”
- The “Compiler compliance level” field shows the Java version being used.
- Go to “Window” > “Preferences” > “Java” > “Installed JREs.”
- Check the details of the JRE being used to confirm the JDK path and version.
3. How to Install Java
3.1 Installation Procedure on Windows
Download the JDK from the Oracle Official Site
- Open your browser and access the Oracle official downloads page.
- Find the latest “Java SE Development Kit (JDK)” and select the installer for Windows (
.exeformat). - Agree to the license to start downloading.
Installing Using the Installer
Once the download finishes, run the installer and proceed with the following steps:- The default installation directory is generally fine.
- The installation finishes in a few minutes.
Setting Environment Variables (Important)
To use Java from the command line, you need to configure environment variables.- Open “Control Panel” > “System” > “Advanced system settings” > “Environment Variables.”
- Select
Pathfrom the “System variables” and add the path to thebinfolder (e.g.C:\Program Files\Java\jdk-17\bin). - Create a new variable named
JAVA_HOMEand specify the JDK path.
java -version in Command Prompt to confirm proper installation.3.2 Installation Procedure on macOS
Downloading and Installing the JDK
- Access the official Oracle page and download the JDK for macOS (
.pkgformat). - Double-click the downloaded file to launch the installer and follow the on-screen instructions.
Checking Installation and Setting Environment Variables in Terminal
After the installation, open Terminal and run the following command:java -versionIf the displayed version is the latest one, the installation was successful. If needed, write the following in your .zshrc or .bash_profile to set JAVA_HOME:export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATHRun source ~/.zshrc afterwards to apply the change.3.3 Installation Procedure on Linux
Installing via Package Manager (Ubuntu/Debian Based)
sudo apt update
sudo apt install openjdk-17-jdkThen check the version:java -version
javac -versionInstalling via Package Manager (CentOS/RHEL Based)
sudo yum install java-17-openjdk-develSwitching Versions When Multiple Versions Are Installed
On Ubuntu, you can switch installed Java versions using the following command:sudo update-alternatives --config javaManual Installation (Using tar.gz file)
- Download the JDK in
.tar.gzformat from the Oracle official website. - Extract it under directories like
/usr/lib/jvm/. - Manually configure symbolic links and environment variables.
4. How to Update Java
4.1 Updating Java on Windows
Manual Update via the Java Control Panel
If JRE is installed on Windows, you can update it with the following steps:- Open the Start menu, type “Java,” and open “Configure Java.”
- Click the “Update” tab.
- Click “Update Now” to start checking for and installing the latest version.
How to Manually Re-Install the JDK
Updating the JDK is done by “downloading and installing the latest version.”- Access the Oracle official page.
- Download the latest JDK (you may delete the old one).
- After installation, reconfigure
JAVA_HOMEandPathif necessary.
4.2 Updating Java on macOS
Updating via the Java Control Panel (for JRE)
- Open “System Settings” > “Java” to open the Control Panel.
- Click the “Update” tab.
- Execute “Update Now.”
How to Update the JDK
On macOS, installing the latest JDK manually is also the common approach.- Download the latest version from the Oracle official site or a JDK distribution site such as Adoptium.
- Double-click the
.pkgfile to install. - If the old version is no longer needed, you may uninstall it.
Don’t Forget to Reconfigure JAVA_HOME
When switching to a new version, the JAVA_HOME path may change.
Reset it with:export JAVA_HOME=$(/usr/libexec/java_home)4.3 Updating Java on Linux
Updating via Package Manager
In Linux environments, you can update Java using the OS package manager. Ubuntu / Debian based:sudo apt update
sudo apt upgrade openjdk-17-jdkCentOS / RHEL based:sudo yum update java-17-openjdk-develSwitching Between Multiple Installed Versions
If both new and old JDK versions coexist, you need to manually switch the active version:sudo update-alternatives --config java
sudo update-alternatives --config javacAn interactive list will appear — simply select the version you want to use.
Manual Update (Using tar.gz)
If you want to install a specific version without depending on packages, you can download a tar.gz JDK, extract it, and manually configure paths and environment variables. Simply remove the old JDK and apply the new settings.5. Common Issues and Troubleshooting
5.1 When “java is not recognized as an internal or external command” Appears While Checking Versions
Cause
- The Java path is not set in the
Pathenvironment variable. - Java is not installed correctly.
Solution
- Confirm that the JDK is installed correctly.
- Add the Java
bindirectory to thePathenvironment variable (example):
C:\Program Files\Java\jdk-17\bin- Restart Command Prompt and execute
java -versionagain.
5.2 Multiple Java Versions Coexist and an Unintended Version Is Used
Cause
- Multiple JDK/JRE installations exist — and the version used differs depending on environmental variable priority.
Solution (Windows / macOS / Linux)
- Use
where java(Windows) orwhich java(macOS/Linux) via the command line to locate the currently used Java executable. - Explicitly write the desired Java path in
Path(Windows) or in.zshrc/.bash_profile. - On Linux, use
update-alternativesto switch versions.
5.3 Build Errors Occur in IDEs like Eclipse (Example: “Compiler compliance level does not match”)
Cause
- The Java version configured in the project differs from the JDK version recognized by Eclipse.
Solution
- In Eclipse, open “Window” → “Preferences” → “Java” → “Installed JREs” to confirm the JDK path.
- Right-click the project → “Properties” → “Java Compiler” and adjust the “Compiler compliance level” (e.g. match to Java 17).
5.4 Old Versions Remain After Updating Java
Cause
- Java does not overwrite old versions — it leaves them as-is.
- Leaving multiple versions can lead to configuration mistakes or security risks.
Solution
- Delete unnecessary versions from “Apps & Features” (Windows) or
/Library/Java/JavaVirtualMachines/(macOS). - After deleting, confirm that
PathandJAVA_HOMEare updated correctly.
5.5 “Unsupported major.minor version” Appears in Java Web Apps
Cause
- The Java version used to compile the application differs from the Java version used at runtime (example: built on Java 17 → run on Java 8).
Solution
- Check the runtime Java version and explicitly set the target version when compiling (example:
javac -target 1.8). - Or upgrade the Java version on the runtime environment.
6. FAQ (Frequently Asked Questions)
Here we summarize questions frequently asked by beginners and intermediate users regarding Java versions, along with practical and easy-to-understand answers. We focus on high-search-demand topics.Q1. What is the difference between JRE and JDK?
A: JRE (Java Runtime Environment) is an environment for “running” applications built in Java. JDK (Java Development Kit) is a complete toolset for “developing, compiling, and running” Java programs. Developers generally need to install the JDK.Q2. What does the Java version number mean?
A: A Java version is expressed like “Java 17.0.2.”- The first number “17” is the major version (Java 17)
- “0” is the minor version
- “2” is the update number
Q3. Is it okay to have multiple Java versions installed?
A: Yes, multiple versions can coexist. However, you must explicitly specify which version to use, so that unintended versions are not invoked.update-alternatives is used on Linux, while on Windows/macOS the key point is managing Path and JAVA_HOME.Q4. Should I uninstall older Java versions?
A: As a general rule, yes — removing unnecessary versions is recommended. To reduce security risk, delete old unused JRE/JDK versions and adjust environment variables to the latest settings.Q5. How do I switch between Java versions?
A: Windows:- Manually configure
PathandJAVA_HOME. - Batch files or dedicated tools may also be used to switch between multiple versions.
- Edit
.bash_profileor.zshrcand setexport JAVA_HOME=.... - On macOS, you can also easily switch versions by using
/usr/libexec/java_home -v <version>.
Q6. I frequently receive Java update notifications. Is it safe to ignore them?
A: If it is not related to active development or execution, ignoring them temporarily usually causes little operational trouble. However — from a security standpoint — updating early is strongly recommended. Especially in enterprise systems or web apps, staying on the latest version is critical.7. Summary
Java versioning is an extremely important factor that affects development environment stability, application compatibility, and even security. Problems caused by mismatched versions are not rare at all. In this article, we systematically explained:- How to check Java versions (command line, GUI, IDE)
- Installation procedures per OS (Windows / macOS / Linux)
- How to safely perform updates and points to note
- Common real-world issues and solutions
- Frequently asked questions that beginners often get stuck on


