Install Java & Set Up the JDK
To start writing Java you need the JDK (Java Development Kit) — not just the JRE. The JDK bundles the compiler (javac), the launcher (java), and the standard library. Download JDK 25 (the current Long-Term Support release), install it, point JAVA_HOME at it, and confirm it works with java --version. That is the whole job, and this article walks through it on all three major operating systems.
Why the JDK and not just "Java"?
When people say "install Java" they often mean the runtime that runs apps. As a learner you need more: you need to compile .java source files into .class bytecode. That compiler ships only in the JDK. Choose an LTS release (currently JDK 25) so the version stays supported and you avoid chasing six-monthly feature releases while learning.
Step 1 — Download the JDK
Open a trustworthy distributor. Oracle's official builds live at oracle.com/java, and there are excellent open-source builds from Eclipse Temurin (Adoptium), Amazon Corretto, and Microsoft. Any of these gives you a standards-compliant JDK 25. Pick the installer that matches your operating system and CPU (most modern machines are 64-bit; Apple Silicon Macs use the aarch64/arm64 build).
Step 2 — Install
- Windows: Run the
.msiinstaller. Tick the option to setJAVA_HOMEand updatePATHif the installer offers it. - macOS: Run the
.pkginstaller, or use a package manager. The JDK lands under/Library/Java/JavaVirtualMachines/. - Linux: Use your distribution's package manager (for example
apt,dnf) or unpack the.tar.gzinto/opt.
Step 3 — Set JAVA_HOME and PATH
Many tools (Maven, Gradle, IDEs) read the JAVA_HOME environment variable to find your JDK.
# macOS / Linux — add to ~/.zshrc or ~/.bashrc, then restart the terminal
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-25.jdk/Contents/Home" # adjust path
export PATH="$JAVA_HOME/bin:$PATH" # so 'java' and 'javac' are found
On Windows, open Environment Variables, add JAVA_HOME pointing to the install folder (the one that contains a bin directory), and add %JAVA_HOME%\bin to Path.
Step 4 — Verify the installation
Open a fresh terminal (so it picks up the new variables) and run:
java --version # prints the runtime version, e.g. "java 25 ..."
javac --version # prints the compiler version, e.g. "javac 25"
If both print version 25, you are ready. If the shell says "command not found", PATH is not pointing at the JDK's bin folder — recheck Step 3.
Want to learn this properly?
Join the waitlist for our courses — beginner-friendly, project-first classes in Jalgaon.
Browse coursesStep 5 — Run your first program
Create a file named Hello.java:
// Hello.java — your first Java program.
// The class name must match the file name (Hello).
public class Hello {
public static void main(String[] args) {
// main is the entry point the JVM calls when the program starts.
System.out.println("Namaste from Jalgaon!");
}
}
Compile and run it:
javac Hello.java # produces Hello.class (bytecode)
java Hello # runs the class; prints: Namaste from Jalgaon!
Since JDK 11 you can even skip the explicit compile step for single-file programs:
java Hello.java # compiles in memory and runs in one shot — great for quick tests
Common mistakes
- Installing the JRE, not the JDK. Only the JDK has
javac. Ifjavac --versionfails butjava --versionworks, you installed the wrong package. - Forgetting to restart the terminal. Environment variables set in a config file only apply to new shell sessions.
- File name not matching the public class.
public class Hellomust live inHello.java, exactly — Java is case-sensitive. JAVA_HOMEpointing one level too deep or too shallow. It must point at the folder that directly containsbin.- Mixing two JDKs. If you install several versions,
PATHorder decides which one wins. Check withwhich java(macOS/Linux) orwhere java(Windows).
FAQ
Do I need an IDE first? No. A text editor and the command line are enough to learn. IntelliJ IDEA, Eclipse, or VS Code help later, but the terminal teaches you what is really happening.
LTS or the newest release? Stick with the LTS (JDK 25) while learning. Feature releases ship every six months and are fine for experiments, but LTS keeps your setup stable.
Keep going
Next, learn how Java stores information in Variables & Data Types in Java. Browse all tutorials on the Java hub, and when you want guided, hands-on practice in Jalgaon, see the Java course.
Ready to learn Java with structured guidance and live mentorship at Infoplanet, Jalgaon? Join the waitlist for the Java course and we will reach out when the next batch opens.
Want to learn this properly?
Join the waitlist for our courses — beginner-friendly, project-first classes in Jalgaon.
Browse coursesFounder, Infoplanet
Atul Kabra founded Infoplanet in 2001 and has spent over two decades teaching programming — C, C++, Java, databases and more — to students across Maharashtra.
Related guides
Arrays in Java
Store many values of one type with Java arrays: declaring, initializing, indexing, iterating, multidimensional arrays, and the Arrays helper class.
Classes & Objects in Java
Define classes with fields and methods, create objects with new, use the this keyword, and understand instance vs static members in Java.
The Java Collections Framework
Use the Java Collections Framework — List, Set, and Map with ArrayList and HashMap — plus generics and iteration, to store flexible groups of objects.
