Fading Coder

One Final Commit for the Last Sprint

Home > Notes > Content

Setting Up the Java Development Kit (JDK) on Your System

Notes 2

The process for installing and configuring the Java Development Kit (JDK) involves the following key actions.

1. Acquire the JDK Package

  • Navigate to the official Oracle website or an alternative JDK provider such as Adoptium or Microsoft Build of OpenJDK.
  • Select and download the appropriate JDK version for your operating system (e.g., Windows, macOS, Linux) and architecture (e.g., x64, ARM64).
  • Official source: https://www.oracle.com/java/technologies/downloads/

2. Execute the Installer

  • Launch the downloaded installer file. This is typically an .exe file on Windows, a .dmg or .pkg file on macOS, or a .tar.gz or .deb archive on Linux.

3. Complete the Installation

  • Follow the prompts provided by the installation wizard. You may choose a custom installation directory if required.

4. Configure System Environment Variables

After installation, you must set environment variables so your system can locate Java commands. This primarily involves defining the JAVA_HOME variable and updating the PATH.

  • Windows:
    1. Open System Properties > Advanced > Environment Variables.
    2. Under "System variables", click "New". Create a varibale named JAVA_HOME and set its value to the JDK installation path (e.g., C:\Program Files\Java\jdk-21).
    3. Find the Path variable in the same list, select it, and click "Edit". Add a new entry: %JAVA_HOME%\bin.
  • macOS / Linux: Open a terminal and edit your shell configuration file (e.g., ~/.bashrc, ~/.zshrc, or ~/.profile) using a text editor like nano or vim.
    export JAVA_HOME=/usr/lib/jvm/jdk-21
    export PATH=$JAVA_HOME/bin:$PATH
    
    Replace /usr/lib/jvm/jdk-21 with the actual path to your JDK installation.

5. Verify the Installation

Open a new command prompt or terminal window and run the following commands:

java -version
javac -version

These should output version information for the Java Runtime Environment (JRE) and the Java compiler, respectively, confirming a successful setup.

6. Manage Multiple JDK Versions (Optional)

If you have several JDK versions installed, you can configure the default version using system-specific tools:

  • On Linux, you can use update-alternatives --config java.
  • On macOS with Homebrew, you can use jenv or set JAVA_HOME directly.

7. Configure Integrated Development Environments (IDEs)

When using an IDE like IntelliJ IDEA, Eclipse, or VS Code, you need to point it to your JDK installation path within the IDE's project or global settings.

8. Apply Environment Changes

On macOS and Linux, you must either start a new terminal session or run the source command to load the updated configuration (e.g., source ~/.bashrc). On Windows, you may need to restart applications or the system for the new PATH to take full effect.

Tags: JavaJDK

Related Articles

Designing Alertmanager Templates for Prometheus Notifications

How to craft Alertmanager templates to format alert messages, improving clarity and presentation. Alertmanager uses Go’s text/template engine with additional helper functions. Alerting rules referenc...

Deploying a Maven Web Application to Tomcat 9 Using the Tomcat Manager

Tomcat 9 does not provide a dedicated Maven plugin. The Tomcat Manager interface, however, is backward-compatible, so the Tomcat 7 Maven Plugin can be used to deploy to Tomcat 9. This guide shows two...

Skipping Errors in MySQL Asynchronous Replication

When a replica halts because the SQL thread encounters an error, you can resume replication by skipping the problematic event(s). Two common approaches are available. Methods to Skip Errors 1) Skip a...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.