A Complete Guide to Java Version Management: Checking, Installing, Updating, and Troubleshooting

目次

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
Since detailed procedures are introduced for each major OS — Windows, macOS, and Linux — and verification methods using developer tools are also explained, the content is structured so it can be applied in any environment. The goal is to help you acquire accurate knowledge about Java versions and set up a safe and comfortable development environment.

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:
  1. Open the Terminal (macOS/Linux) or Command Prompt (Windows).
  2. Enter and execute the following command:
java -version
Example 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 -version
Example Output:
javac 17.0.2

Checking 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 java
By 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

  1. Open the Start menu, type “Java,” and open “Configure Java.”
  2. Click the “Java” tab and select “View.”
  3. A list of installed Java versions will appear.
With this method, even if multiple versions coexist, you can check them in a list.

2.3 Checking via GUI (macOS)

You can also check the Java version via GUI on macOS.

Checking from System Settings

  1. From the Apple menu, open “System Settings” > “Java.”
  2. The Java Control Panel will launch.
  3. Select the “Java” tab and click “View.”
As with Windows, you can check detailed version information.

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:
  1. Launch Eclipse and right-click the target project.
  2. Go to “Properties” > “Java Compiler.”
  3. The “Compiler compliance level” field shows the Java version being used.
You can also check the version of the JDK used by Eclipse itself with the following steps:
  1. Go to “Window” > “Preferences” > “Java” > “Installed JREs.”
  2. 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

  1. Open your browser and access the Oracle official downloads page.
  2. Find the latest “Java SE Development Kit (JDK)” and select the installer for Windows (.exe format).
  3. 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.
  1. Open “Control Panel” > “System” > “Advanced system settings” > “Environment Variables.”
  2. Select Path from the “System variables” and add the path to the bin folder (e.g. C:\Program Files\Java\jdk-17\bin).
  3. Create a new variable named JAVA_HOME and specify the JDK path.
After completing the configuration, run java -version in Command Prompt to confirm proper installation.

3.2 Installation Procedure on macOS

Downloading and Installing the JDK

  1. Access the official Oracle page and download the JDK for macOS (.pkg format).
  2. 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 -version
If 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:$PATH
Run 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-jdk
Then check the version:
java -version
javac -version

Installing via Package Manager (CentOS/RHEL Based)

sudo yum install java-17-openjdk-devel

Switching Versions When Multiple Versions Are Installed

On Ubuntu, you can switch installed Java versions using the following command:
sudo update-alternatives --config java

Manual Installation (Using tar.gz file)

  1. Download the JDK in .tar.gz format from the Oracle official website.
  2. Extract it under directories like /usr/lib/jvm/.
  3. Manually configure symbolic links and environment variables.
This method is useful when you want to use the latest version or a specific JDK distribution.

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:
  1. Open the Start menu, type “Java,” and open “Configure Java.”
  2. Click the “Update” tab.
  3. Click “Update Now” to start checking for and installing the latest version.
This method applies only to JRE. If you are using a development JDK, the basic approach is to manually reinstall the latest version from the Oracle official site.

How to Manually Re-Install the JDK

Updating the JDK is done by “downloading and installing the latest version.”
  1. Access the Oracle official page.
  2. Download the latest JDK (you may delete the old one).
  3. After installation, reconfigure JAVA_HOME and Path if necessary.

4.2 Updating Java on macOS

Updating via the Java Control Panel (for JRE)

  1. Open “System Settings” > “Java” to open the Control Panel.
  2. Click the “Update” tab.
  3. Execute “Update Now.”

How to Update the JDK

On macOS, installing the latest JDK manually is also the common approach.
  1. Download the latest version from the Oracle official site or a JDK distribution site such as Adoptium.
  2. Double-click the .pkg file to install.
  3. 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-jdk
CentOS / RHEL based:
sudo yum update java-17-openjdk-devel

Switching 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 javac
An 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 Path environment variable.
  • Java is not installed correctly.

Solution

  1. Confirm that the JDK is installed correctly.
  2. Add the Java bin directory to the Path environment variable (example):
C:\Program Files\Java\jdk-17\bin
  1. Restart Command Prompt and execute java -version again.

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) or which 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-alternatives to 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

  1. In Eclipse, open “Window” → “Preferences” → “Java” → “Installed JREs” to confirm the JDK path.
  2. 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 Path and JAVA_HOME are 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
Since Java 9 and later, Java follows a time-based release schedule — releasing new versions every six months. LTS (Long-Term Support) versions are especially important in enterprise environments (e.g., Java 8, 11, 17, 21).

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 Path and JAVA_HOME.
  • Batch files or dedicated tools may also be used to switch between multiple versions.
macOS / Linux:
  • Edit .bash_profile or .zshrc and set export 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
By understanding and applying these points correctly, you will gain confidence in Java version management. Especially for those who are about to learn Java or who want to set up a fresh development environment, being able to smoothly handle JDK installation, version switching, and updating directly leads to skill improvement. Environment preparation greatly influences both productivity and motivation in programming. Use this article as a reference and build a reliable and up-to-date Java environment.