java_home in ubuntu code example
Example 1: how to set java_home in ubuntu
sudo apt update
sudo apt install openjdk-8-jdk -y
ls /usr/lib/jvm/java-8-openjdk-amd64/
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
echo $JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
echo $PATH
java -version
Example 2: ubuntu change default java path
sudo update-alternatives --config java
Example 3: set java_home permanently ubuntu
sudo gedit /etc/profile
JAVA_HOME=/usr/lib/jvm/{your jdk path}
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH