Java 17 remains the baseline for many Spring Boot 3.x, Jenkins, Gradle, Android tooling, and older Minecraft server workflows that are not ready for newer Java branches. To install OpenJDK 17 on Arch Linux, use Arch’s official jdk17-openjdk package for development work, or choose one of the matching runtime packages when you only need to run Java applications.
Arch can keep several Java major versions installed side by side, but the Java 17 JDK and JRE variants conflict with each other because the larger packages already provide the smaller runtime layers. The unversioned jdk-openjdk package tracks Arch’s newest OpenJDK feature release, so use jdk17-openjdk when a project specifically requires Java 17.
Install OpenJDK 17 on Arch Linux
Choose an OpenJDK 17 Package
Arch publishes the Java 17 packages in the official extra repository. Choose one package from the JDK/JRE group; the full JDK is the safest default because it includes the compiler, runtime, and development tools.
| Package | Includes | Best Fit |
|---|---|---|
| jdk17-openjdk | Full Java 17 JDK, runtime, compiler, and tools | Development, build tools, and general use |
| jre17-openjdk | Java 17 runtime with desktop GUI support | Running desktop Java apps without compiling code |
| jre17-openjdk-headless | Java 17 runtime without desktop GUI libraries | Server workloads and command-line Java tools |
| openjdk17-doc | Offline Java 17 API documentation | Optional after the full JDK is installed |
| openjdk17-src | OpenJDK 17 source files | Optional after the full JDK is installed |
For normal Arch systems, skip generic Java download pages and install one of these packages through pacman so file ownership and updates stay package-managed.
The documentation and source packages depend on jdk17-openjdk, so install them only after choosing the full JDK path. If your search intent is a Docker image such as openjdk:17 or an Alpine openjdk17 package, keep that separate from this host install flow; start with installing Docker on Arch Linux when you need local container tooling.
Update Arch Linux Before Installing OpenJDK 17
Synchronize package databases and apply pending upgrades before installing Java. On a rolling-release system, this avoids mixing a new package with stale dependencies.
sudo pacman -Syu
These commands use
sudofor tasks that need root privileges. If your user is not in the sudoers file yet, run the commands as root or follow the guide on how to add and manage sudo users on Arch Linux.
Install the OpenJDK 17 JDK
Install the full Java 17 development kit when you need java, javac, build tools, or framework tooling that compiles source code.
sudo pacman -S jdk17-openjdk
Confirm that pacman installed the package branch you requested. The exact patch release changes as Arch updates the package, but the package name should match jdk17-openjdk.
pacman -Q jdk17-openjdk
Relevant output starts with:
jdk17-openjdk 17.0.x
Install a Runtime-Only OpenJDK 17 Package
Use the runtime package only when you run Java applications and do not need javac. The GUI runtime is appropriate for Swing or AWT desktop applications.
sudo pacman -S jre17-openjdk
For a server, container host, or command-line-only Java application, install the headless runtime instead.
sudo pacman -S jre17-openjdk-headless
Do not install the Java 17 JRE package after the Java 17 JDK. The JDK already provides the runtime, and pacman treats the same-branch JDK, JRE, and headless JRE packages as conflicting package variants.
Install Optional Documentation or Source Files
If you installed jdk17-openjdk, add only the optional package you need. Install the offline API documentation when you want local Javadoc reference material.
sudo pacman -S openjdk17-doc
Install the source package separately when a debugger or IDE needs JDK source stepping.
sudo pacman -S openjdk17-src
Verify OpenJDK 17 on Arch Linux
Check the active Java runtime. Patch numbers vary with Arch package updates, but the major version should stay on 17.
java -version
Relevant output starts with:
openjdk version "17.0.x" OpenJDK Runtime Environment OpenJDK 64-Bit Server VM
If you installed the full JDK, confirm the Java compiler is available.
javac -version
The compiler should report the same Java 17 branch:
javac 17.0.x
Test the OpenJDK 17 JDK with a Sample Program
Use this compile-and-run test after installing the full JDK. Runtime-only installs do not include javac, so they can stop after the java -version check. Create a temporary source file in the current directory.
cat > HelloWorld.java <<'EOF'
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Arch Java 17!");
}
}
EOF
Compile the file and run the resulting class.
javac HelloWorld.java
java HelloWorld
Expected output:
Hello, Arch Java 17!
Remove the temporary files after the test if you no longer need them.
rm -f HelloWorld.java HelloWorld.class
Manage Java Versions on Arch Linux
Arch installs the archlinux-java helper through java-runtime-common. Use it to view installed Java environments and set the default when Java 17 coexists with newer or older branches.
List Installed Java Environments
Check the available Java environments and the current default.
archlinux-java status
Example output on a system with multiple branches installed:
Available Java environments: java-17-openjdk (default) java-21-openjdk
The environment marked (default) is the branch used by unqualified java and javac commands.
Set OpenJDK 17 as the Default Java Version
Set Java 17 as the system default when another installed branch is currently active.
sudo archlinux-java set java-17-openjdk
Verify the selected branch after switching.
java -version
The first line should report the Java 17 branch. The Arch Wiki Java documentation covers additional archlinux-java behavior, including how default JVM symlinks work.
Use OpenJDK 17 for One Application
You do not need to change the system default when only one application needs Java 17. Call the Java 17 binary directly, or set JAVA_HOME only for that command.
JAVA_HOME=/usr/lib/jvm/java-17-openjdk /usr/lib/jvm/java-17-openjdk/bin/java -jar app.jar
Update OpenJDK 17 on Arch Linux
OpenJDK 17 updates arrive through normal Arch package upgrades. Keep Java 17 package-managed with pacman instead of layering a manually downloaded JDK over the same system paths.
sudo pacman -Syu
Check the installed Java 17 variant after the upgrade if a project depends on this branch.
for package in jdk17-openjdk jre17-openjdk jre17-openjdk-headless; do
pacman -Q "$package" 2>/dev/null
done
The output shows whichever Java 17 variant is installed:
jdk17-openjdk 17.0.x
Troubleshoot OpenJDK 17 on Arch Linux
Java Command Not Found After Installation
If java -version fails after installation, the shell may not have refreshed its Java profile scripts or the default Java environment may be unset.
bash: java: command not found
First, confirm that one of the Java 17 packages is installed.
for package in jdk17-openjdk jre17-openjdk jre17-openjdk-headless; do
pacman -Q "$package" 2>/dev/null
done
If the command prints no package, return to the install section and choose the JDK or runtime package you need. If a package is present, relevant output starts with the installed package name:
jdk17-openjdk 17.0.x
Refresh the current shell profile and clear Bash’s command hash.
source /etc/profile
hash -r
java -version
If the package is installed but no default environment is set, repair Arch’s Java symlinks.
sudo archlinux-java fix
archlinux-java status
Relevant output should list a valid Java 17 environment, for example:
Available Java environments: java-17-openjdk (default)
Pacman Reports a Java 17 Package Conflict
The Java 17 JDK, GUI runtime, and headless runtime are alternate variants of the same branch. If pacman asks to remove jre17-openjdk or jre17-openjdk-headless while installing jdk17-openjdk, that is expected because the JDK already provides the runtime.
Confirm the package metadata if you want to verify the conflict before replacing anything.
pacman -Si jdk17-openjdk | grep '^Conflicts With'
Relevant output shows the same-branch runtime variants that conflict with the full JDK:
Conflicts With : jre17-openjdk jre17-openjdk-headless
Choose the package variant you actually need, then let pacman replace the conflicting Java 17 variant. Keep other major versions, such as Java 21, installed if another project depends on them.
JAVA_HOME Is Required by an Application
Arch Java packages do not need JAVA_HOME for normal command-line use. When an application specifically checks this variable, point it at Arch’s default JVM symlink for the current shell session.
export JAVA_HOME=/usr/lib/jvm/default
echo "$JAVA_HOME"
Expected output:
/usr/lib/jvm/default
Use /usr/lib/jvm/java-17-openjdk instead when a script must point to Java 17 even after you switch the system default to another branch.
Wrong Java Version After Switching
If java -version still shows another branch after running archlinux-java set, list the exact environment names and set the Java 17 entry again.
archlinux-java status
sudo archlinux-java set java-17-openjdk
java -version
If the status output shows a broken default link, run the repair command and check the status again.
sudo archlinux-java fix
archlinux-java status
Remove OpenJDK 17 from Arch Linux
Remove optional documentation or source packages first if you installed them. They depend on jdk17-openjdk, so removing them first avoids dependency errors when you remove the JDK.
for package in openjdk17-doc openjdk17-src; do
if pacman -Q "$package" >/dev/null 2>&1; then
sudo pacman -Rns "$package"
fi
done
Preview the recursive removal for the full JDK before deleting it. The preview uses -Rs because pacman does not combine --print with -n.
sudo pacman -Rs jdk17-openjdk --print
Remove the JDK after reviewing the package list.
sudo pacman -Rns jdk17-openjdk
If you installed a runtime-only package instead, remove the matching runtime package.
sudo pacman -Rns jre17-openjdk
For the headless runtime, use this package name instead.
sudo pacman -Rns jre17-openjdk-headless
Verify that the Java 17 packages from this article are no longer installed. This loop also confirms that optional documentation or source packages are gone if you removed them earlier.
for package in jdk17-openjdk jre17-openjdk jre17-openjdk-headless openjdk17-doc openjdk17-src; do
if pacman -Q "$package" >/dev/null 2>&1; then
echo "$package is still installed"
else
echo "$package is not installed"
fi
done
Expected output after removing all Java 17 packages covered here:
jdk17-openjdk is not installed jre17-openjdk is not installed jre17-openjdk-headless is not installed openjdk17-doc is not installed openjdk17-src is not installed
If other Java branches remain installed, run
archlinux-java statusafter removal and set a new default if needed. If OpenJDK 17 was your only Java installation, unqualifiedjavacommands will stop working until you install another Java package.
Conclusion
OpenJDK 17 is available on Arch through the package variant that matches your workload, with archlinux-java handling default JVM selection when multiple branches coexist. For JVM work beyond a basic Java install, install Kotlin on Arch Linux once the Java runtime is ready.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>