codegurukool.com · Free coding tutorials & online compiler

Home › Java Tutorial › Java installation

Java installation

Full step-by-step installation for Windows, macOS and Linux.

Windows

  1. Open adoptium.net and download the latest LTS Temurin JDK (.msi).
  2. Run the installer. On the Custom Setup page choose Set JAVA_HOME variable and Add to PATH.
  3. Click Install and then Finish.

macOS

  1. Download the .pkg installer from adoptium.net and run it. Or run brew install --cask temurin.

Linux (Ubuntu or Debian)

  1. Run sudo apt update.
  2. Run sudo apt install default-jdk.

Check the installation

  1. Open a new terminal.
  2. Run java -version and then javac -version. Both should print a version.

Run your first program

  1. Create a file named Main.java and paste the code from the editor below.
  2. In the terminal, go to that folder.
  3. Compile with javac Main.java. This creates Main.class.
  4. Run it with java Main.

If something goes wrong

Example code

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

Run this code in the online editor

← Java introductionJava get started →