archlinux-java
Manage and switch Java environment implementations
TLDR
List installed Java environments
Return the short name of the current default Java environment
Set the default Java environment
Unset the default Java environment
Fix an invalid/broken default Java environment configuration
SYNOPSIS
archlinux-java status|get|set [environment]
PARAMETERS
status
Lists all available Java environments, paths, and marks current default with *
get
Prints the name of the currently set default Java environment
set environment
Sets specified Java environment as default (must run as root)
DESCRIPTION
archlinux-java is an Arch Linux-specific utility for handling multiple Java Runtime Environments (JREs) and Java Development Kits (JDKs). It simplifies switching between different Java versions installed via pacman, such as OpenJDK variants.
The tool interacts with environments in /usr/lib/jvm/, where each is identified by a name like java-17-openjdk or java-8-openjdk. Pacman installation creates these directories and registers them with the tool.
Key functions include listing all available environments with the current default marked, retrieving the active environment name, and setting a new default. Setting the default updates symlinks in /usr/bin/ for commands like java, javac, and sets JAVA_HOME via /etc/profile.d/jre.sh, affecting all users after relogin or source.
This ensures consistent Java usage system-wide without manual symlink management, integrating with Arch's package system via hooks.
CAVEATS
Requires root privileges for set; Java environments must be installed via pacman for proper registration; changes require relogin or sourcing /etc/profile for environment variables.
EXAMPLES
archlinux-java status
archlinux-java get
sudo archlinux-java set java-17-openjdk
source /etc/profile
ENVIRONMENT NAMES
Use exact names from status output, e.g., java-11-openjdk, java-8-openjdk/jre for JRE-only.
HISTORY
Introduced in Arch Linux around 2012-2013 as part of java-common or jre packages to handle growing multi-version Java needs, leveraging pacman hooks for automatic environment registration during installs/upgrades.
SEE ALSO
update-alternatives(8), pacman(8), java(1)


