Arch Linux: set a Java version

By | 05/07/2020
 

A short note about HowTo install and set a specific Java version when you have various versions installed.

Will use the  archlinux-java script, see the Switching between JVM.

Install a package itself, here it will be Oracle Java 14:

yay -S jdk
:: Checking for conflicts...
:: Checking for inner conflicts...
[Aur: 2]  jre-14.0.1-1  jdk-14.0.1-1
...

Check currently used – in this case, it’s old OpenJDK 11:

java --version
openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10)
OpenJDK 64-Bit Server VM (build 11.0.6+10, mixed mode)

List all installed versions:

archlinux-java status
Available Java environments:
java-11-openjdk (default)
java-14-jdk
java-8-jdk

Set the Oracle Java 14 as the active version to be used by default now:

sudo archlinux-java set java-14-jdk

Check again:

java --version
java 14.0.1 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

Done.