Java Tutorial Series: This lesson is part of our comprehensive Complete Java Tutorial: Learn Java from Beginner to Advanced.
How to Install Java: Complete JDK Installation Guide
Before you can write and run Java programs, you need a Java Development Kit (JDK) installed on your computer. The JDK provides the tools required to compile Java source code, run applications, and develop Java projects.
This guide explains what you need to install, how the JDK differs from the Java runtime, how to install Java on Windows, macOS, and Linux, how to configure the command line, how to verify the installation, and how to troubleshoot common setup problems.
For current Java releases, Oracle's download and installation documentation lists JDK packages for Windows, macOS, and Linux. As of 2026, JDK 27 is the latest Java SE release and JDK 25 is the current Long-Term Support (LTS) release. For a learning environment, choose a version that matches the requirements of the projects or course you are following. citeturn0search0turn0search5
What You Will Learn
- JDK, JRE, and JVM basics
- Which Java package you need for development
- How to choose a Java version
- How to install Java on Windows
- How to install Java on macOS
- How to install Java on Linux
- How to verify java and javac
- How PATH and JAVA_HOME affect Java development
- How to choose and configure an IDE
- How to troubleshoot common Java installation problems
1. What Do You Need to Install Java?
If your goal is to learn Java programming or develop Java applications, install the JDK rather than looking only for a runtime environment. The JDK contains the development tools needed to create and compile Java programs. Oracle's installation documentation explicitly describes the JDK as the package to download when you want to develop or run Java applications. citeturn0search4
| Component | Purpose | Do You Need It to Learn Java? |
|---|---|---|
| JDK | Development kit containing the compiler and other development tools | Yes |
| JRE | Runtime components used to run Java applications | You normally get the runtime capability with a modern JDK |
| JVM | Virtual machine that executes Java bytecode | Yes, but it is part of the Java platform rather than a separate beginner download |
2. What Is the JDK?
The Java Development Kit is the main software package used to develop Java applications. It includes the Java runtime and developer tools such as the Java compiler.
Java source code (.java) → javac compiler → bytecode (.class) → JVM → program output
The JDK is therefore what you use when you move from simply understanding Java concepts to actually writing, compiling, testing, and running Java programs.
3. Which Java Version Should You Install?
Java is released in feature versions, and some releases are designated Long-Term Support (LTS). The right version depends on your project, employer, course, framework, and deployment environment.
| Choice | When It Makes Sense |
|---|---|
| Latest feature release | Useful when you want the newest Java features and are working with compatible tooling. |
| LTS release | A strong choice for learning, long-lived projects, and environments that prioritize extended stability. |
| Project-required version | Use the version explicitly required by an existing project, framework, or organization. |
Do not choose a version only because it has the highest number. Compatibility with your learning materials and project tooling matters.
4. How to Install Java on Windows
Step 1 — Download the JDK
Open the official Java downloads page and select the Windows package that matches your system architecture. Current Oracle downloads provide Windows x64 installer options for supported JDK releases. citeturn0search0
Step 2 — Run the Installer
Open the downloaded installer and follow the installation wizard. Keep the installation location in mind because it can be useful when configuring environment variables or troubleshooting.
Step 3 — Open a New Terminal
After installation, open a new Command Prompt or PowerShell window. A new terminal ensures that updated environment settings are loaded.
Step 4 — Verify Java
java -version
Step 5 — Verify the Compiler
javac -version
If both commands return a Java version, the command-line setup is generally working.
5. How to Install Java on macOS
Oracle provides macOS JDK installers and archives for supported processor architectures, including Intel and Apple silicon variants where available. Select the package that matches your Mac. citeturn0search0
Step 1 — Download the JDK
Download the appropriate macOS JDK package from the official Java distribution page.
Step 2 — Install the JDK
Open the installer and complete the installation steps.
Step 3 — Verify the Installation
java -version
javac -version
If the commands work from Terminal, your JDK is available to command-line tools.
6. How to Install Java on Linux
Linux installation options depend on the distribution and the JDK package you choose. Oracle's installation guide documents archive, Debian package, and RPM-based installation approaches for Linux. citeturn0search10
Option 1 — Package Manager
On a distribution with a suitable package repository, using the system package manager is often convenient because it can manage installation and updates.
Option 2 — JDK Package or Archive
You can also install a downloaded JDK package or archive. The exact command depends on your Linux distribution and package format.
Verify
java -version
javac -version
If multiple JDKs are installed, your distribution may provide mechanisms for selecting the active Java executable. The exact command varies by distribution.
7. Understanding PATH and JAVA_HOME
Two environment concepts frequently appear when configuring Java development: PATH and JAVA_HOME.
| Setting | Purpose |
|---|---|
| PATH | Tells the operating system where executable commands such as java and javac can be found. |
| JAVA_HOME | Points to the JDK installation directory and is commonly used by build tools and development software. |
You do not always need to configure these variables manually when an installer or development environment has already configured the system. If java or javac cannot be found, however, PATH is one of the first things to check.
Checking the Java command location
where java
where javac
On Linux or macOS, a common command for locating an executable is:
which java
which javac
8. How to Test Your Java Installation
The best test is to compile and run a small Java program.
public class Main {
public static void main(String[] args) {
System.out.println("Java is installed correctly.");
}
}
Save the file as Main.java, then compile it:
javac Main.java
If compilation succeeds, run the generated class:
java Main
You should see:
Java is installed correctly.
This verifies more than the version command: it confirms that the JDK compiler and Java runtime can work together for a basic program.
9. Installing an IDE for Java
You can learn Java using a terminal and a text editor, but an Integrated Development Environment (IDE) can make larger projects easier to manage.
- IntelliJ IDEA
- Eclipse
- Visual Studio Code with appropriate Java tooling
- Other Java-compatible development environments
An IDE can provide code completion, navigation, debugging, project management, build integration, and error highlighting. However, beginners should still understand how javac and java work because those concepts remain useful when troubleshooting builds and environments.
10. Common Java Installation Problems
'java' is not recognized or command not found
The JDK may not be installed correctly, or the Java executable may not be available through PATH. Open a new terminal first, then check the installation and PATH configuration.
'javac' is not recognized
This often indicates that the JDK compiler is missing from PATH or that only a runtime-oriented installation is being used. Verify that a full JDK is installed.
Wrong Java version appears
Multiple Java installations may exist. Check which java executable your terminal is using and inspect your PATH or platform-specific Java selection settings.
IDE cannot find Java
The IDE may be configured to use a different JDK or may not have detected the installed JDK. Select the intended JDK in the IDE's project or SDK settings.
Project requires a different Java version
Use the Java version required by the project. Modern development often involves projects that deliberately target a specific Java release for compatibility.
11. JDK Installation Checklist
- Install a JDK, not just a runtime.
- Choose a version compatible with your learning material or project.
- Verify java -version.
- Verify javac -version.
- Compile a small .java program.
- Run the compiled class.
- Check PATH if commands are not found.
- Configure JAVA_HOME when a build tool or environment requires it.
- Configure your IDE to use the intended JDK.
12. What Should You Do After Installing Java?
Installation is only the starting point. Once Java is working, write a small Hello World program, learn Java syntax, and then move through variables, data types, operators, conditions, loops, methods, and data structures.
A useful progression is:
Install JDK → Verify setup → Hello World → Syntax → Variables & Data Types → Conditions & Loops → Methods → Data Structures → OOP → Advanced Java
13. Frequently Asked Questions
Do I need the JDK to learn Java?
Yes. If you want to develop and compile Java programs, the JDK is the appropriate package.
Is JRE enough for Java development?
A development workflow requires the JDK. Modern JDK distributions include the runtime components needed to run Java programs.
Which Java version should a beginner install?
Use a supported version that matches your learning resources. An LTS release is often a practical choice for a stable learning environment.
How do I check whether Java is installed?
Run java -version and javac -version in a new terminal.
Why does javac not work when java works?
The compiler may not be installed or may not be available through PATH. Verify that a full JDK is installed.
Do I need an IDE to learn Java?
No. You can compile Java from the command line. An IDE becomes useful as projects become larger.
Can I have multiple Java versions installed?
Yes, but you need to understand which version your terminal, IDE, and build tools are using.
Conclusion
Installing Java correctly gives you the foundation needed to begin programming. The key is to install a suitable JDK, verify both java and javac, and successfully compile and run a small program.
Once your environment is ready, the next step is not to spend more time configuring tools. Start writing Java code and build your understanding progressively.
Continue with the Java Hello World Program and then move into Java syntax and core programming concepts.