Yandex

Java Advanced ConceptsJava Advanced Concepts3

Java ReferenceJava Reference1

Install Java on Windows 11
Step-by-Step Instructions



Install Java on Windows 11

This tutorial will walk you through installing the Java Development Kit (JDK) on a Windows 11 machine.

Step 1: Download the Java JDK

Visit the official Oracle website to download the latest version of the JDK:

https://www.oracle.com/java/technologies/javase-downloads.html

Choose the version labeled “Windows x64 Installer” under the latest Java SE version. Click to download the .exe installer file.

Step 2: Install the JDK

  1. Run the downloaded installer.
  2. Click “Next” on the welcome screen.
  3. Choose the installation location (default is usually fine) and click “Next.”
  4. Installation begins. Wait for it to complete and click “Close.”

Java is now installed, but we still need to configure it so your system knows how to find Java tools.

Step 3: Set Up Environment Variables

To make Java accessible from the command line, you need to add it to your system's environment variables:

  1. Search for "Environment Variables" in the Windows Start menu and open it.
  2. Under “System Properties,” click Environment Variables.
  3. In the “System Variables” section, find and select Path, then click Edit.
  4. Click New and add the path to the bin folder inside your JDK installation. (e.g., C:\Program Files\Java\jdk-21\bin)
  5. Click OK on all windows to save the changes.

Step 4: Verify the Installation

Open Command Prompt and type the following commands:

java -version
java version "21.0.1" 2024-10-17 LTS
Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-123)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-123, mixed mode)
javac -version
javac 21.0.1

If you see version numbers instead of errors, congratulations! Java is successfully installed and configured.

Step 5: Write Your First Java Program

Let’s test your Java setup by writing a simple program.

Create a file called HelloWorld.java using any text editor (like Notepad).

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Java is successfully installed!");
    }
}

Step 6: Compile and Run the Program

Open Command Prompt in the directory where your HelloWorld.java file is saved and run:

javac HelloWorld.java

This command compiles your Java code. If successful, it will generate a HelloWorld.class file (the bytecode).

Now run the compiled program:

java HelloWorld
Java is successfully installed!

Perfect! You’ve just written and executed your first Java program.

Troubleshooting Tips



Welcome to ProgramGuru

Sign up to start your journey with us

Support ProgramGuru.org

You can support this website with a contribution of your choice.

When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.

PayPal

UPI

PhonePe QR

MALLIKARJUNA M