Note
Change the jdk.gz filename or folder name, based in your verion JDK downloaded as example I use the jdk-20.0.1
Preparing Artefacts
- Access the official JDK website and Download a version available or compatible with your project
- Extract with
tar -xvf jdk-20.0.1.tar.gz
- Move extracted folder
sudo mv jdk-20.0.1 /opt/
Configuring global binaries
- Create symbolic link appointing to jdk binaries
sudo ln -s /opt/jdk-20/bin/java /usr/bin/java
sudo ln -s /opt/jdk-20/bin/javac /usr/bin/javac
- Or configure manually the env variable
JAVA_HOME
in$HOME/.config/config.fish
set -x JAVA_HOME /opt/jdk-20.0.1
set -x PATH $JAVA_HOME/bin $PATH
Important
If your default shell is zsh
or bash
, is need change the syntax and edit the respectives files .zshrc
or .bashrc
- Reload shell
source $HOME/.config/config.fish
# zsh
source $HOME/.zshrc
# bash
source $HOME/.bashrc
- Test
java -version
Output:
openjdk version "20.0.1" 2023-04-18
OpenJDK Runtime Environment (build 20.0.1+9-29)
OpenJDK 64-Bit Server VM (build 20.0.1+9-29, mixed mode, sharing)