Java Installation & Setup

Java Installation & Setup (Step-by-Step Guide)
To write and run Java programs, you need to install:
- JDK (Java Development Kit)
- A Code Editor or IDE like VS Code, IntelliJ IDEA, or Eclipse
Step 1: Download Java JDK
Go to the official Oracle or OpenJDK website:
(Search: “Download JDK latest version”)Choose your operating system:
Windows (x64 Installer)
macOS
Linux
Download the installer and run it.
Step 2: Install JDK
During installation:
Click Next → Accept → Install → Finish
Default installation path (Windows example):
Step 3: Set Environment Variables (Windows Only)
This step allows Java commands like
javacandjavato work in Command Prompt.
Open Environment Variables:
Press Windows Key → Search: Environment Variables
Click: Edit system environment variables
Click: Environment Variables
Set JAVA_HOME
Under System Variables → New
Variable name:
JAVA_HOMEVariable value: The JDK installation path, e.g.,
Add to PATH
Select variable: Path → Edit → New
Add:
Step 4: Verify Installation
Open Command Prompt (CMD) and type:
You should see something like:
Then type:
You should see:
Step 5: Install an IDE (Optional but Recommended)
| IDE | Best For |
|---|---|
| IntelliJ IDEA | Most popular, powerful for beginners & pros |
| Eclipse | Mostly used in enterprise |
| VS Code | Lightweight and simple |
VS Code Setup (Optional)
If using Visual Studio Code:
Install VS Code
Open Extensions panel (Ctrl+Shift+X)
Install:
Java Extension Pack
Debugger for Java
Language Support for Java by Red Hat
Step 6: Write First Java Program
Create a file named:
Paste:
Step 7: Compile & Run
Open terminal in the folder containing the file and run:
This will create a file: Hello.class
Now run:
Output:
Congratulations!
You have successfully installed Java and executed your first program!
