By the end of this module, you will be able to:
JAVA_HOME is and why it mattersThe Java Development Kit (JDK) is the software package you install on your machine to write, compile, and run Java programs. It contains three main components:
| Component | Full Name | What it does |
|---|---|---|
| JVM | Java Virtual Machine | Executes your compiled Java program |
| JRE | Java Runtime Environment | The libraries and files the JVM needs to run |
| Dev Tools | Development Tools | Command-line tools for compiling, packaging, and documenting code |
Think of it this way: the JRE is the engine, the JVM is what runs your code inside that engine, and the dev tools are the toolkit you use to build things.
When you install the JDK, you get these tools available in your terminal:
| Tool | Command | What it does | JS/Node Equivalent |
|---|---|---|---|
| Compiler | javac |
Converts .java source code into .class bytecode |
tsc (TypeScript Compiler) |
| Launcher | java |
Starts the JVM and runs your compiled program | node index.js |
| Archiver | jar |
Packages your code into a single .jar file |
npm pack / Webpack |
| Documentation | javadoc |
Generates HTML docs from your code comments | JSDoc |
You won't use all of these immediately, but it's good to know they exist. For now, javac and java are the two you'll use the most — and your IDE will often run them for you behind the scenes.
Java is an open standard, which means different organisations can build and distribute their own version of the JDK as long as they comply with the official specification. They all run the same Java code — the difference is who builds and maintains them.
| Distribution | Provider | Cost | Recommended for |
|---|---|---|---|
| OpenJDK | Oracle / Community | Free | General use, the reference implementation |
| Temurin | Adoptium (Eclipse) | Free | Most popular choice for production |
| Corretto | Amazon | Free | AWS-hosted applications |
| Oracle JDK | Oracle | Paid (commercial) | Enterprise with Oracle support contracts |
| Zulu | Azul | Free / Paid | Broad platform support |
| GraalVM | Oracle / Community | Free / Paid | Performance-critical or polyglot apps |
<aside> 💡
For this track we use OpenJDK 21 — it's free, widely used, and the version most tools and frameworks support well. Any other free distribution would also work fine.
</aside>
Follow the instructions for your operating system. If you're not sure which one you have, ask your coach before starting.
Windows
macOS
Linux (Ubuntu / Debian)
Once the installation is complete, close and reopen your terminal, then run:
javac -version
You should see output like:
javac 21.0.x
Also verify the runtime:
java -version
Expected output:
openjdk version "21.0.x" ...
<aside> ⚠️
If you see an error like javac: command not found, try closing and reopening your terminal first. If the error persists, your PATH may not include the JDK's bin folder — see the JAVA_HOME section below or ask your coach.
</aside>
For more help, visit the official installation guide: https://openjdk.org/install/
JAVA_HOMEMany Java tools — including IntelliJ IDEA, Maven, and Gradle — look for an environment variable called JAVA_HOME. This variable holds the path to the root folder of your JDK installation, so these tools can find the JDK without you having to configure each one manually.
# macOS / Linux
echo $JAVA_HOME
# Windows (PowerShell)
echo $env:JAVA_HOME
If it prints a path (e.g. /usr/lib/jvm/java-21-openjdk-amd64), you're good. If it prints nothing, you may need to set it — IntelliJ can usually handle this automatically, but some build tools need it explicitly.
<aside> 💡
In practice, IntelliJ IDEA detects your JDK automatically when you create a project. You only need to set JAVA_HOME manually if a command-line build tool like Maven or Gradle can't find your JDK. Ask your coach if you run into this.
</aside>
As you work on different projects, you may encounter ones that require different Java versions. SDKMAN! is the standard tool for installing and switching between multiple JDK versions from the terminal — similar to nvm for Node.js.
It works on macOS, Linux, and Windows (via WSL):
# Install SDKMAN!
curl -s "<https://get.sdkman.io>" | bash
# Install a specific JDK
sdk install java 21.0.2-open
# Switch between versions
sdk use java 21.0.2-open
# List available versions
sdk list java
<aside> 💡
You don't need SDKMAN! right now, but it's worth knowing it exists. It becomes very useful once you start working on multiple Java projects professionally.
</aside>
More information: https://sdkman.io/
IntelliJ IDEA is the industry-standard IDE for Java development. It handles compiling, running, debugging, and much more — so you can focus on writing code rather than managing tools.
hello-java), and click CreateIntelliJ will create a src folder. Right-click it → New → Java Class → name it Main.
Paste this code:
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Run it by clicking the green play button next to main, or press Shift + F10.
You should see in the output panel at the bottom:
Hello, World!
<aside> 🎉
</aside>