I am trying to work with jshell of Java 9. So for that i installed the JDK 9 on my Mac, where i already had the JDK 8 installed.
All my projects, workspaces, Hadoop, Spark and dependent APIs are using JDK 8. So for the current scenario, i can not move all my projects to work with JDK 9.
So what i want is a small utility or a smart way to switch between JDK 8 and JDK 9 on demand basis.
For the time being, what i am doing is:
Open a terminal.
kv:micro-tab karan.verma$ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
Set the JAVA_HOME temporarily to jdk 9
kv:Home karan.verma$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
start the jshell
kv:Home karan.verma$ jshell | Welcome to JShell -- Version 9.0.1 | For an introduction type: /help intro
close the terminal when done. That means, the global JAVA_HOME works now.
kv:micro-tab karan.verma$ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
So, my question is, Is there is any better approach to do it? Or this is the a good practice to do such kind of things? Please suggest.