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

  1. Go to the official Oracle or OpenJDK website:
    👉 (Search: “Download JDK latest version”)

  2. Choose your operating system:

    • Windows (x64 Installer)

    • macOS

    • Linux

  3. Download the installer and run it.


Step 2: Install JDK

During installation:

  • Click Next → Accept → Install → Finish

  • Default installation path (Windows example):

    C:\Program Files\Java\jdk-21

Step 3: Set Environment Variables (Windows Only)

This step allows Java commands like javac and java to work in Command Prompt.

1️⃣ Open Environment Variables:

  • Press Windows Key → Search: Environment Variables

  • Click: Edit system environment variables

  • Click: Environment Variables

2️⃣ Set JAVA_HOME

  • Under System Variables → New

  • Variable name: JAVA_HOME

  • Variable value: The JDK installation path, e.g.,

    C:\Program Files\Java\jdk-21

3️⃣ Add to PATH

  • Select variable: Path → Edit → New

  • Add:

    %JAVA_HOME%\bin

Step 4: Verify Installation

Open Command Prompt (CMD) and type:

java -version

You should see something like:

java version "21.0.2"

Then type:

javac -version

You should see:

javac 21.0.2

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:

  1. Install VS Code

  2. Open Extensions panel (Ctrl+Shift+X)

  3. Install:

    • Java Extension Pack

    • Debugger for Java

    • Language Support for Java by Red Hat


Step 6: Write First Java Program

Create a file named:

Hello.java

Paste:



 


Step 7: Compile & Run

Open terminal in the folder containing the file and run:

javac Hello.java

This will create a file: Hello.class

Now run:

java Hello

Output:

Java setup successful!

🎉 Congratulations!

You have successfully installed Java and executed your first program!

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *