How to Install and Set Up Java 25 on Your System

Java 25 is the latest version of the Java Development Kit (JDK), packed with performance improvements and new features. In this guide, you’ll learn how to install Java 25 on your system and write your first “Hello, World!” program using the new classless main method feature.

Tip: Java 25 introduces the ability to write simple programs without needing a class declaration. Perfect for beginners!


Prerequisites

Before we begin, make sure you have:

  • A computer with Windows, macOS, or Linux
  • A terminal or command prompt
  • Internet connection to download the JDK

Step 1: Download Java 25

  1. Go to the official JDK page: https://jdk.java.net/25

  2. Under Java SE Development Kit 25, choose the right version for your OS:

    • Windows: jdk-25_windows-x64_bin.zip or .msi
    • macOS: jdk-25_macos-x64_bin.tar.gz or .dmg
    • Linux: jdk-25_linux-x64_bin.tar.gz
  3. Download the installer or archive file.


Step 2: Install Java 25

Windows

  • If you downloaded the .msi file:

    • Double-click it and follow the installation wizard.
  • If you downloaded the .zip file:
    • Extract it to C:\Program Files\Java\jdk-25

Set up the environment variables:

setx JAVA_HOME "C:\Program Files\Java\jdk-25"
setx PATH "%JAVA_HOME%\bin;%PATH%"

macOS

Using tar.gz:

sudo mkdir -p /Library/Java/JavaVirtualMachines
sudo tar -xzf jdk-25_macos-x64_bin.tar.gz -C /Library/Java/JavaVirtualMachines/

Set environment variables (edit ~/.zshrc or ~/.bash_profile):

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-25.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

Linux

Using tar.gz:

tar -xvzf jdk-25_linux-x64_bin.tar.gz
sudo mv jdk-25 /usr/lib/jvm/jdk-25

Update your environment (~/.bashrc or ~/.zshrc):

export JAVA_HOME=/usr/lib/jvm/jdk-25
export PATH=$JAVA_HOME/bin:$PATH

Then run:

source ~/.bashrc  # or source ~/.zshrc

Step 3: Verify the Installation

Open a terminal and type:

java -version

You should see something like:

java version "25" 2025-09-17
Java(TM) SE Runtime Environment (build 25+36)
Java HotSpot(TM) 64-Bit Server VM (build 25+36, mixed mode)

Step 4: Write Your First Java 25 Program

Java 25 allows you to write simple programs without declaring a class! Let’s try it.

  1. Create a file named Hello.java:
    void main() {
        System.out.println("Hello, Java 25!");
    }
    

    This is called classless main method syntax – available since JDK 21, but very useful in Java 25 for quick scripts!

  2. Compile and run it using:

java Hello.java

You’ll see:

Hello, Java 25!

You’re all set!


What’s Next?

Now that you’ve installed Java 25, try exploring:

  • Java 25 features like pattern matching, unnamed classes, class-file API
  • Writing simple scripts using .java files directly
  • Exploring new APIs introduced in Java 25

Stay tuned for more tutorials on using Java 25 effectively!


Summary

Step Action
1 Download Java 25 from jdk.java.net
2 Install based on your OS
3 Set JAVA_HOME and update PATH
4 Run java -version to verify
5 Create and run your first program

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.