# 1. Install more than one Java versions(via Ubuntu PPAs by "webupd8"). sudo apt-get install \ oracle-java7-installer oracle-java7-unlimited-jce-policy \ oracle-java8-installer oracle-java8-unlimited-jce-policy \ oracle-java9-installer oracle-java9-unlimited-jce-policy # The above command will install 3 Java versions under the following # paths in my environment: ls /usr/lib/jvm/java-7-oracle/ ls /usr/lib/jvm/java-8-oracle/ ls /usr/lib/jvm/java-9-oracle/
# 3. Modify my "zshrc". If you use bash, write to ".bashrc". echo"source ~/.jvm/jvm.sh" >> ~/.zshrc
# 4. Create "~/.jvmconfig" file with the following content: 7=/usr/lib/jvm/java-7-oracle 8=/usr/lib/jvm/java-8-oracle 9=/usr/lib/jvm/java-9-oracle
# 5. Set the JVM version you want to use: # Set Java 7 as default: jvm global 7 # Check if the setting works: jvm version which java java -version # Set Java 9 as default: jvm global 9 # Check if the setting works: jvm version which java java -version