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 -versionIf 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
- Download: Go to the Oracle Java Downloads page.
- Installer: Download the x64 Installer (
.exefile). - Run: Double-click the downloaded file and follow the installation wizard.
- 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
Pathvariable, click "Edit", and add%JAVA_HOME%\bin.
macOS
- Download: Go to the Oracle Java Downloads page.
- Installer: Download the x64 DMG Installer (or Arm 64 DMG Installer for M1/M2/M3 chips).
- Run: Open the
.dmgfile and follow the instructions. - Verify: Open a new terminal and run
java -version.
Linux (Ubuntu/Debian)
Open your terminal and run:
sudo apt update
sudo apt install default-jdkVerify the installation:
java -version3. 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.
| IDE | Best For | Cost |
|---|---|---|
| IntelliJ IDEA | Professionals & Beginners | Free (Community) / Paid (Ultimate) |
| Eclipse | Enterprise Development | Free (Open Source) |
| VS Code | Lightweight Development | Free |
| BlueJ | Learning / Education | Free |
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.
- Open your terminal/command prompt.
- Type
javac -versionand press Enter.- If you see something like
javac 17.0.1, the compiler is ready.
- If you see something like
- Type
java -versionand 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
javacis not recognized, it usually means yourJAVA_HOMEorPathenvironment 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 →
