You can install multiple Java virtual machines (JVM) on your Raspberry Pi and switch between them as needed. After installing the JVMs that you want, use the following command to select the default JVM/JRE.
sudo update-alternatives --config java
With the new JVM selected, you can test and verify that is is the new default by executing the java command using the version argument.
java -version
You should a response displaying the selected java version and VM:
* Raspberry Pi is a trademark of the Raspberry Pi foundation.
* Oracle and Java are registered trademarks of Oracle.