⚙️ [2] Setting Up Java (JDK + IDE) — From Installation to First Line of Code!

⚙️ [2] Setting Up Java (JDK + IDE) — From Installation to First Line of Code!

⚙️ [2] Setting Up Java (JDK + IDE) — From Installation to First Line of Code!

🔍 Why Setup Matters

Before writing any Java code, your machine needs the right tools. Just like a carpenter needs their saws and levels, a Java developer needs a properly configured setup — starting with the Java Development Kit (JDK) and an Integrated Development Environment (IDE).

Get this right, and you'll be able to code, compile, and debug with ease. Get it wrong, and even printing “Hello World” becomes a nightmare. Let's do it the right way.

☕ What is JDK?

The Java Development Kit (JDK) is a software bundle required to develop Java applications. It includes:

  • javac — Java compiler
  • java — Java launcher for the JVM
  • Standard libraries — Collections, IO, Networking, etc.
  • Tools — jlink, jarsigner, javadoc, etc.

✅ Think of it as your entire Java toolbox.

📥 Step-by-Step: Installing JDK 24.0.2

🖥️ Windows — Installing & Setting Environment Variables

  1. 🔗 Download the official ZIP: 👉 openjdk-24.0.2_windows-x64_bin.zip
  2. 🗂️ Unzip the folder to:
    C:\Program Files\Java\jdk-24.0.2
    or any safe location without spaces
  3. 🛠️ Set environment variables:
    • JAVA_HOME → Go to System Properties → Environment Variables → "System variables" → Click New
      Name: JAVA_HOME
      Value: C:\Program Files\Java\jdk-24.0.2 *(❗ do NOT include \bin)*
    • Path → Find the Path variable → Edit → Add: %JAVA_HOME%\bin
  4. ✅ Open Command Prompt and verify setup:
    [INPUT]: java -version
    You should see [OUTPUT]:
    openjdk version "24.0.2" 2025-07-15
    OpenJDK Runtime Environment (build 24.0.2+12-54)
    OpenJDK 64-Bit Server VM (build 24.0.2+12-54, mixed mode, sharing)
    [INPUT]: javac -version
    You should see [OUTPUT]:
    javac 24.0.2

🍎 macOS — Download & Configure

  1. 🔗 Download the tar.gz: 👉 openjdk-24.0.2_macos-x64_bin.tar.gz
  2. Unpack and move to:
    /Library/Java/JavaVirtualMachines/
  3. Set environment:
    echo 'export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-24.0.2.jdk/Contents/Home"' >> ~/.zshrc
    echo 'export PATH="$JAVA_HOME/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc

🐧 Linux — Install via tar.gz (Manual)

  1. 🔗 Download: 👉 openjdk-24.0.2_linux-x64_bin.tar.gz
  2. Extract & move to `/usr/lib/jvm/`:
    sudo mkdir -p /usr/lib/jvm
    sudo tar -xvzf openjdk-24.0.2_linux-x64_bin.tar.gz -C /usr/lib/jvm/
  3. Configure environment:
    export JAVA_HOME=/usr/lib/jvm/jdk-24.0.2
    export PATH=$JAVA_HOME/bin:$PATH
    Add the above to your `~/.bashrc` or `~/.zshrc`

💻 Installing an IDE — IntelliJ or VS Code

🔷 IntelliJ IDEA

  1. Download: JetBrains IntelliJ
  2. New Project → Java → Choose JDK 24.0.2
  3. Create Java class:
    public class HelloJava {
      public static void main(String[] args) {
        System.out.println("It works!");
      }
    }
  4. Click ▶️ Run

🟦 Visual Studio Code

  1. Install: VS Code
  2. Install Java Extension Pack: Extension Pack for Java
    📦 Identifier: vscjava.vscode-java-pack
  3. Create a file HelloVSCode.java:
    public class HelloVSCode {
      public static void main(String[] args) {
        System.out.println("VS Code + Java is ready!");
      }
    }
  4. Right-click → Run Java or press Ctrl + F5
  5. If prompted for JDK path, use:
    C:\Program Files\Java\jdk-24.0.2
    Or add to settings.json:
    "java.home": "C:\\Program Files\\Java\\jdk-24.0.2"

📦 Running from Terminal

// HelloWorld.java
public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello from CLI!");
  }
}
// Terminal
javac HelloWorld.java
java HelloWorld

⚠️ Common Mistakes

  • ❌ JAVA_HOME includes \bin — it shouldn't!
  • ❌ Didn't add %JAVA_HOME%\bin to Path
  • ❌ Forgot to restart terminal or VS Code
  • ❌ VS Code extension not installed — install vscode-java-pack

✅ Recap

With OpenJDK 24.0.2 properly installed and your environment configured, you're ready to dive into Java development. Choose your favorite IDE, and you're set to write your first Java program — with no setup headaches.

Visit jdk.java.net or Adoptium for latest builds & options.

In our next post, we’ll dive into 📘 [3] Java Syntax & Basics — Structure, Statements, and Starting Right!

— Blog by Aelify (ML2AI.com)