Example using installed openjdk-21. You need to add these lines to the shell configuration file in .bashrc or .zshrc
export JAVA_HOME=/usr/lib64/openjdk-21
export PATH=$PATH:$JAVA_HOME/bin
Reload the configuration: source ~/.bashrc
Check: java -version