Check out example codes for "linux change java". It will help you in understanding the concepts better.

Code Example 1

sudo update-alternatives --config java

Code Example 2

sudo update-java-alternatives -s java-8-oracle
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/
export PATH=$PATH:$JAVA_HOME
123

Learn ReactJs, React Native from akashmittal.com