Installation

Step-by-step guide to installing Java JDK on Windows, macOS, and Linux.

To start programming in Java, you need to install the Java Development Kit (JDK). The JDK contains the tools you need to build and run Java programs.


1. Check if Java is already installed

Open your terminal (Command Prompt on Windows) and type:

java -version

If you see a version number (e.g., java version "17.0.1"), Java is already installed! If not, follow the steps below.


2. Install JDK

We recommend installing the Oracle JDK or OpenJDK.

Windows

  1. Download: Go to the Oracle Java Downloads page.
  2. Installer: Download the x64 Installer (.exe file).
  3. Run: Double-click the downloaded file and follow the installation wizard.
  4. Environment Variable:
    • Search for "Environment Variables" in Windows Search.
    • Click "Edit the system environment variables".
    • Click "Environment Variables".
    • Under "System variables", click "New".
    • Variable name: JAVA_HOME
    • Variable value: Path to your JDK installation (e.g., C:\Program Files\Java\jdk-17).
    • Find the Path variable, click "Edit", and add %JAVA_HOME%\bin.

macOS

  1. Download: Go to the Oracle Java Downloads page.
  2. Installer: Download the x64 DMG Installer (or Arm 64 DMG Installer for M1/M2/M3 chips).
  3. Run: Open the .dmg file and follow the instructions.
  4. Verify: Open a new terminal and run java -version.

Linux (Ubuntu/Debian)

Open your terminal and run:

sudo apt update
sudo apt install default-jdk

Verify the installation:

java -version

3. Choose a Code Editor (IDE)

While you can write Java code in Notepad, an Integrated Development Environment (IDE) makes life much easier with features like code completion, debugging, and error highlighting.

IDEBest ForCost
IntelliJ IDEAProfessionals & BeginnersFree (Community) / Paid (Ultimate)
EclipseEnterprise DevelopmentFree (Open Source)
VS CodeLightweight DevelopmentFree
BlueJLearning / EducationFree

Recommendation 💡: We highly recommend IntelliJ IDEA Community Edition for beginners. It's powerful, free, and industry-standard.


4. Verify Installation

Let's make sure everything is set up correctly.

  1. Open your terminal/command prompt.
  2. Type javac -version and press Enter.
    • If you see something like javac 17.0.1, the compiler is ready.
  3. Type java -version and press Enter.
    • If you see the version, the runtime is ready.

Common Pitfalls

[!WARNING] JRE vs JDK: Installing just the JRE (Java Runtime Environment) allows you to run Java programs but not write them. You must install the JDK to develop.

[!IMPORTANT] Path Issues: If javac is not recognized, it usually means your JAVA_HOME or Path environment variable is not set correctly.

What's Next?

Now that your environment is ready, let's learn about the core components of Java. Understand JVM, JRE, and JDK →