Java Installation

Learn how to install Java step by step on Windows. This guide explains JDK installation, environment variables, and running your first Java program.

What is Java Installation?

Before writing Java programs, you need to install Java Development Kit (JDK) on your computer. JDK contains all tools required to develop and run Java applications.

JDK includes Java Compiler, JVM, JRE, and development tools.

What is JDK?

JDK stands for Java Development Kit. It helps developers write, compile, and execute Java programs.

Step 1 - Download Java

Open your browser and visit the official Oracle Java website.

Download the latest JDK version according to your operating system.

Supported Operating Systems

Windows users should download the .exe installer.

Step 2 - Install Java

After downloading the installer:

After installation is completed, click Close.

Step 3 - Set Environment Variables

Environment variables allow Java commands to run from anywhere in the command prompt.

Create JAVA_HOME Variable

Variable Name: JAVA_HOME

Variable Value:
C:\Program Files\Java\jdk-21

Update Path Variable

%JAVA_HOME%\bin

Step 4 - Verify Java Installation

Open Command Prompt and type:

java -version

If Java is installed correctly, the installed version will appear.

Check Java Compiler

javac -version

javac command checks whether Java compiler is installed properly.

Your First Java Program

Create a file named Hello.java and write the following code:

public class Hello {

    public static void main(String[] args) {

        System.out.println("Hello Java");

    }

}

Compile the Program

javac Hello.java

Run the Program

java Hello

Output

Hello Java

Popular Java Editors

Common Java Installation Errors

  • Java command not recognized
  • Incorrect JAVA_HOME path
  • Path variable not updated
  • Old Java version conflict

Conclusion

Java installation is the first step toward becoming a Java developer. Once Java is installed correctly, you can start building Java applications, Android apps, and enterprise software.