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

Code Example 1

# on linux
sudo update-alternatives --config java
# then just input the number of the jdk you
# want to use as default and hit Enter

Code Example 2

/usr/libexec/java_home -V  
export JAVA_HOME=`/usr/libexec/java_home -v 1.6.0_65-b14-462` //java 8

Learn ReactJs, React Native from akashmittal.com