Install the JDK & Set Up
Before you can write Java, you need a JDK (Java Development Kit) on your computer. In this lesson you will install Java 25 LTS, make sure your terminal can find it, try out Java's interactive shell, and choose an editor.
The whole process takes about ten minutes. Most problems beginners face later ("javac is not recognized", "wrong version") come from a messy setup, so it is worth doing carefully once.
Choose a JDK build
Java's source code lives in the open-source OpenJDK project. Several companies build installers from that same code. They behave the same way for learning, so pick one and move on.
| Build | From | Notes |
|---|---|---|
| Eclipse Temurin | Adoptium (Eclipse Foundation) | Free, popular, easy installers. Used in this lesson. |
| Oracle JDK | Oracle | Official Oracle build; read its licence if you use it at work. |
| Amazon Corretto | Amazon | Free, used on AWS. |
| Microsoft Build of OpenJDK | Microsoft | Free, used on Azure. |
Always choose version 25 (the current LTS) and the JDK, not a JRE.
Install on Windows
The simplest way is the official MSI installer from adoptium.net. Choose Windows, x64 (or aarch64 for ARM laptops), JDK, version 25, and download the .msi file. While installing:
- Keep Add to PATH switched on (it is on by default).
- Switch on Set JAVA\_HOME variable. It is off by default, and build tools such as Maven look for it.
If you prefer the command line, Windows 10 and 11 include the winget package manager. Open PowerShell and run:
winget install EclipseAdoptium.Temurin.25.JDKClose and reopen your terminal after installing, so it picks up the new PATH.
Install on macOS and Linux
On macOS you can use the .pkg installer from adoptium.net, or Homebrew:
brew install --cask temurin@25On Ubuntu 26.04 LTS, Java 25 is the default JDK, so either command below works. On other distributions, use your package manager or the packages listed on adoptium.net.
sudo apt update
sudo apt install openjdk-25-jdkCheck your installation
Open a new terminal and ask both the runtime and the compiler for their versions:
java -version
javac -versionYou should see a version starting with 25. The exact update number and date change every three months, so yours may differ. In October 2026 the Temurin output looks like this:
openjdk version "25.0.5" 2026-10-20 LTS
OpenJDK Runtime Environment Temurin-25.0.5+8 (build 25.0.5+8-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.5+8 (build 25.0.5+8-LTS, mixed mode, sharing)
javac 25.0.5If javac prints "not recognized" or "command not found", the JDK's bin folder is not on your PATH. If java -version shows an old version such as 1.8.0, an older Java is earlier on your PATH.
JAVA_HOME and PATH explained
Two environment variables matter:
- PATH is the list of folders your terminal searches when you type a command. The JDK's
binfolder (which holdsjava.exeandjavac.exe) must be in it. - JAVA\_HOME points to the JDK folder itself (the parent of
bin). Maven, Gradle and many IDEs read it to find Java.
On Windows, this PowerShell snippet shows both and lists every java.exe the system can find. The first one listed is the one that runs.
$env:JAVA_HOME
where.exe javaOn a laptop that once had Oracle Java 8, the output might look like this:
C:\Program Files\Eclipse Adoptium\jdk-25.0.5.8-hotspot\
C:\Program Files\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files\Eclipse Adoptium\jdk-25.0.5.8-hotspot\bin\java.exeHere the old Oracle javapath folder comes first, so typing java runs Java 8. Fix it by uninstalling the old Java from Settings > Apps, or by moving the JDK 25 bin entry above it in System Properties > Environment Variables > Path. Then open a new terminal and check again.
Try Java instantly with JShell
The JDK includes JShell, an interactive shell (a REPL: read, evaluate, print, loop). You type a line of Java and see the result at once, without writing a class or compiling. It is perfect for testing small ideas. Start it by typing jshell, and leave with /exit.
jshell> 7 * 24
$1 ==> 168
jshell> String city = "Kochi"
city ==> "Kochi"
jshell> city.length()
$3 ==> 5
jshell> city.toUpperCase()
$4 ==> "KOCHI"JShell stores each result in a variable such as $1, so you can reuse it. You will use JShell throughout this course to check small facts quickly.
Choose an editor
You can write Java in any text editor, but a Java-aware editor underlines mistakes as you type, completes method names and runs programs with one click.
- IntelliJ IDEA from JetBrains: the most popular Java IDE, with a free edition that covers this whole course.
- VS Code with Microsoft's Extension Pack for Java: lighter, good if you already use VS Code.
- Eclipse IDE: free and open source, still common in colleges and companies.
For the first few lessons, use the terminal and a plain editor. Typing javac and java yourself teaches you what an IDE does behind the scenes.
Common mistakes
- Not reopening the terminal. A terminal keeps the PATH it had when it opened. After installing, always open a new one.
- Two Java versions fighting. Use
where.exe java(Windows) orwhich -a java(Linux, macOS) to see every copy and which one wins. - JAVA\_HOME pointing at
bin. It must point to the JDK folder, such asC:\Program Files\Eclipse Adoptium\jdk-25.0.5.8-hotspot, not to itsbinsubfolder. - Installing a JRE by mistake. If
java -versionworks butjavacdoes not exist, you installed a runtime only. Install the JDK.
Key points
- Install a JDK for Java 25 LTS; Eclipse Temurin, Oracle, Amazon and Microsoft builds all come from OpenJDK.
- On Windows use the MSI (switch on "Set JAVA\_HOME variable") or
winget install EclipseAdoptium.Temurin.25.JDK. - Check with
java -versionandjavac -version; both should start with 25. - PATH must contain the JDK's
binfolder; JAVA\_HOME must point to the JDK folder. - JShell lets you run single lines of Java instantly.
Exercise
Install JDK 25, then:
- Run
java -versionandjavac -versionand note the update number. - Run
where.exe java(Windows) orwhich -a java(macOS/Linux). How many copies of Java do you have? - Start JShell and work out how many minutes there are in a week. Then store your city in a variable and print it in capital letters.
Show solution
Both version commands should start with 25. If more than one Java is listed in step 2, make sure the JDK 25 entry is first. In JShell:
jshell> 7 * 24 * 60
$1 ==> 10080
jshell> String city = "Pune"
city ==> "Pune"
jshell> city.toUpperCase()
$3 ==> "PUNE"A week has 10,080 minutes. JShell prints each result straight away, so you do not need System.out.println here.
Quick Quiz
1. Which variable should point to the JDK folder (not its bin folder)?
JAVA_HOME points to the JDK folder; PATH must contain its bin subfolder.
2. java -version prints 1.8.0_401 even though you installed JDK 25. What is the most likely cause?
The first java found on PATH runs, so an old Java 8 entry wins.
3. What is JShell?
JShell is Java's REPL: type a line, see the result straight away.
4. Which MSI option is switched off by default in the Temurin installer?
Add to PATH is on by default; you must switch on Set JAVA\_HOME variable yourself.
Learn Java with a mentor
Free lessons get you started. Our Java, C & C++ Programming training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
