Skip to main content

Command Palette

Search for a command to run...

Step-by-Step Guide to Installing Java

Updated
3 min read
Step-by-Step Guide to Installing Java
F

I'm a Software Engineer with a strong technical background in building impactful SaaS solutions, web applications, and mobile platforms. My expertise spans programming languages like Java, JavaScript, and PHP, alongside frameworks such as Spring Boot, Vue.js, and Node.js. I thrive on creating reliable, scalable, and user-centered applications that solve real-world challenges. Throughout my career, I’ve paired my technical journey with a passion for mentoring and training. As a mentor and trainer, I’ve guided aspiring developers, particularly at institutions like École 229, through immersive learning experiences. My approach combines practical projects, collaborative problem-solving, and innovative teaching methods to foster both technical expertise and essential team dynamics. Beyond coding, I bring a strong set of soft skills—including communication, adaptability, and problem-solving—that enable me to drive successful project outcomes and support the growth of those around me. Some of my most notable achievements include developing a secure e-commerce application following Agile best practices and delivering numerous WordPress sites that enhanced brand presence and user experience for small businesses. Looking ahead, I am eager to transition into a Product Owner role, where I can bridge the gap between technical development and strategic vision. My goal is to leverage my technical expertise, mentoring experience, and user-focused approach to shape products that deliver real value and resonate with their audiences. Feel free to reach out if you'd like to discuss technology, product management, or collaborative projects :)


Introduction

Java is a versatile and widely-used programming language. To start developing in Java, you first need to install the Java Development Kit (JDK) on your machine. This guide will walk you through the steps to install Java on Windows, macOS, and Linux.

Checking for Existing Java Installation

Before installing Java, check if it is already installed on your system.

On Windows

  1. Open Command Prompt.

  2. Type java -version and press Enter.

On macOS

  1. Open Terminal.

  2. Type java -version and press Enter.

On Linux

  1. Open Terminal.

  2. Type java -version and press Enter.

If Java is installed, you will see the version number. If not, proceed with the installation steps below.

Installing Java on Windows

  1. Download the JDK

    • Go to the Oracle JDK download page.

    • Choose the latest JDK version and download the Windows installer (e.g., jdk-XX_windows-x64_bin.exe).

  2. Run the Installer

    • Open the downloaded installer file.

    • Follow the on-screen instructions to complete the installation.

  3. Set Up Environment Variables

    • Open the Start menu, search for "Environment Variables," and select "Edit the system environment variables."

    • In the System Properties window, click on "Environment Variables."

    • Under System Variables, click "New" and add a new variable:

      • Variable name: JAVA_HOME

      • Variable value: Path to your JDK installation (e.g., C:\Program Files\Java\jdk-XX).

    • Edit the Path variable and add %JAVA_HOME%\bin.

Installing Java on macOS

  1. Download the JDK

  2. Install the JDK

    • Open the downloaded .dmg file.

    • Double-click the .pkg installer and follow the instructions.

  3. Set Up Environment Variables

    • Open Terminal.

    • Edit the .bash_profile or .zshrc file (depending on your shell):

        nano ~/.bash_profile
      

      or

        nano ~/.zshrc
      
    • Add the following lines:

        export JAVA_HOME=$(/usr/libexec/java_home)
        export PATH=$JAVA_HOME/bin:$PATH
      
    • Save and close the file, then run source ~/.bash_profile or source ~/.zshrc.

Installing Java on Linux

  1. Download the JDK

  2. Install the JDK

    • Open Terminal.

    • Extract the tar.gz file to /opt:

        sudo tar -xzf jdk-XX_linux-x64_bin.tar.gz -C /opt
      
    • Set up the JAVA_HOME and PATH variables by adding the following lines to your .bashrc or .zshrc file:

        export JAVA_HOME=/opt/jdk-XX
        export PATH=$PATH:$JAVA_HOME/bin
      

      Save and close the file, then run source ~/.bashrc or source ~/.zshrc.

Setting Up Environment Variables

For all operating systems, ensure the environment variables are set correctly:

  • JAVA_HOME: Points to the JDK installation directory.

  • PATH: Includes $JAVA_HOME/bin to ensure Java executables are available globally.

Verifying the Installation

Open a new terminal or command prompt.

  1. Type java -version and press Enter.

  2. You should see the installed Java version, indicating the installation was successful.

  3. terminal java --version

Conclusion

You've successfully installed Java on your system. Now you're ready to start developing Java applications.


More from this blog

Software Engineering and Product

10 posts

Software Engineer | Mentor | Speaker | Aspiring PO