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.
- Contains Java Compiler (javac)
- Includes JVM (Java Virtual Machine)
- Provides JRE (Java Runtime Environment)
- Required for Java development
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
- Linux
- macOS
Windows users should download the .exe installer.
Step 2 - Install Java
After downloading the installer:
- Double click the installer file
- Click Next
- Select installation location
- Click Install
- Wait for installation to complete
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
- Open Windows Search
- Search "Environment Variables"
- Open "Edit the system environment variables"
- Click Environment Variables
- Create a new System 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
- VS Code
- IntelliJ IDEA
- Eclipse
- NetBeans
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.