⚙️ [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
- 🔗 Download the official ZIP: 👉 openjdk-24.0.2_windows-x64_bin.zip
- 🗂️ Unzip the folder to:
or any safe location without spacesC:\Program Files\Java\jdk-24.0.2 - 🛠️ 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
Pathvariable → Edit → Add:%JAVA_HOME%\bin
- JAVA_HOME
→ Go to System Properties → Environment Variables → "System variables" → Click
- ✅ Open Command Prompt and verify setup:
You should see [OUTPUT]:[INPUT]: java -versionopenjdk 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)
You should see [OUTPUT]:[INPUT]: javac -versionjavac 24.0.2
🍎 macOS — Download & Configure
- 🔗 Download the tar.gz: 👉 openjdk-24.0.2_macos-x64_bin.tar.gz
- Unpack and move to:
/Library/Java/JavaVirtualMachines/ - 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)
- 🔗 Download: 👉 openjdk-24.0.2_linux-x64_bin.tar.gz
- 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/ - Configure environment:
Add the above to your `~/.bashrc` or `~/.zshrc`export JAVA_HOME=/usr/lib/jvm/jdk-24.0.2 export PATH=$JAVA_HOME/bin:$PATH
💻 Installing an IDE — IntelliJ or VS Code
🔷 IntelliJ IDEA
- Download: JetBrains IntelliJ
- New Project → Java → Choose JDK 24.0.2
- Create Java class:
public class HelloJava { public static void main(String[] args) { System.out.println("It works!"); } } - Click ▶️ Run
🟦 Visual Studio Code
- Install: VS Code
- Install Java Extension Pack:
Extension Pack for Java
📦 Identifier:vscjava.vscode-java-pack - Create a file
HelloVSCode.java:public class HelloVSCode { public static void main(String[] args) { System.out.println("VS Code + Java is ready!"); } } - Right-click → Run Java or press
Ctrl + F5 - If prompted for JDK path, use:
Or add toC:\Program Files\Java\jdk-24.0.2settings.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%\bintoPath - ❌ 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)