Skip to content
Search Fedora

    Browse this documentation

    Installing Java on Fedora: only OpenJDK 25 ships, so what about 21 or 17

    The trap first: Fedora 45 has no Java 21 and no Java 17 in its repositories.

    Terminal window
    dnf list --available 'java-*-openjdk.x86_64'
    java-25-openjdk.x86_64 1:25.0.4.1.1-1.1.fc45
    java-latest-openjdk.x86_64 1:27.0.0.0.35-0.0.1.0.ea.fc45

    Only two: 25 (the current LTS) and java-latest (a 27 early-access build).

    This is not a broken repo. Compare three generations:

    ReleaseJDKs offered
    F43java-21, java-25, java-latest
    F44java-25, java-latest
    F45java-25, java-latest

    Java 21 was removed in F44. So dnf install java-21-openjdk from an old tutorial ends in No match for argument.

    Terminal window
    sudo dnf install java-25-openjdk

    For server-side programs only, the smaller headless build is enough:

    Terminal window
    sudo dnf install java-25-openjdk-headless

    Verify:

    Terminal window
    java -version
    openjdk version "25.0.4.1" 2026-08-18
    OpenJDK Runtime Environment (Red_Hat-25.0.4.1.1-1) (build 25.0.4.1+1)
    OpenJDK 64-Bit Server VM (Red_Hat-25.0.4.1.1-1) (build 25.0.4.1+1, mixed mode, sharing)

    Where it landed:

    Terminal window
    readlink -f "$(command -v java)"
    java -XshowSettings:properties -version 2>&1 | grep java.home
    /usr/lib/jvm/java-25-openjdk/bin/java
    java.home = /usr/lib/jvm/java-25-openjdk

    Many build tools (Maven, Gradle, Tomcat) require JAVA_HOME, and Fedora does not set it:

    Terminal window
    echo $JAVA_HOME # empty

    Put it in a profile script:

    Terminal window
    sudo tee /etc/profile.d/java.sh >/dev/null <<'EOF'
    export JAVA_HOME=/usr/lib/jvm/java-25-openjdk
    export PATH=$JAVA_HOME/bin:$PATH
    EOF
    source /etc/profile.d/java.sh
    echo $JAVA_HOME
    Terminal window
    cat > Hello.java <<'EOF'
    public class Hello {
    public static void main(String[] args) {
    System.out.println("Java " + System.getProperty("java.version"));
    }
    }
    EOF
    java Hello.java

    Since JDK 11, single-file source execution means no separate javac step:

    Java 25.0.4.1

    The repositories have neither, so there are three routes.

    Terminal window
    podman run --rm eclipse-temurin:21-jdk java -version

    The application runs in the container; the host needs no old JDK. This is also the direction Fedora recommends.

    2. Upstream tarball (when the JDK must be on the host)

    Section titled “2. Upstream tarball (when the JDK must be on the host)”
    Terminal window
    mkdir -p ~/jdk && cd ~/jdk
    curl -LO https://github.com/adoptium/temurin21-binaries/releases/latest/download/OpenJDK21U-jdk_x64_linux_hotspot.tar.gz
    tar xzf OpenJDK21U-jdk_x64_linux_hotspot.tar.gz
    export JAVA_HOME=~/jdk/jdk-21*
    $JAVA_HOME/bin/java -version

    3. SDKMAN (several versions on a dev machine)

    Section titled “3. SDKMAN (several versions on a dev machine)”
    Terminal window
    curl -s "https://get.sdkman.io" | bash
    source ~/.sdkman/bin/sdkman-init.sh
    sdk install java 21.0.5-tem
    sdk use java 21.0.5-tem

    Best when you need to switch between 17/21/25 frequently.

    SymptomCause
    No match for argument: java-21-openjdkremoved since F44 — not a repo problem
    JAVA_HOME is emptyFedora does not set it; write a profile script
    java not found after installingonly -headless installed without JRE, or PATH missing $JAVA_HOME/bin
    wrong version with two JDKs presentuse update-alternatives --config java or change JAVA_HOME