Desktop Java Selection

While trying to get an application analysis tool working on my laptop I discovered that when I originally set it up it only had Java 12 install when I needed to make use of Java 11.
I have never really needed to concern myself with this sort of thing in the past so sprung to Google (and to save me searching again I thought I would summarise my findings). A few things have changed over the last year around Java and Oracle that Oracle are wanting to extract from people (this is a conversation for a different day). The good news is that I had gone with an OpenJDK version on my mac using brew;
|
|
So how do I see what versions of Java are on my system and how to I change?
Whats on my system?
To see the versions available to you run the following;
|
|
Homebrew Cask has a whole host of OpenJDK version available to be install;
|
|
Now if you rerun the original command in this section to check what versions are available on your system you should see multiple versions.
|
|
Great, so now I have Java 11 & 12 on my system but how do I make switch versions?
Switching between versions
I found a couple of different ways to achieve this, the method I chose was to play with the $JAVA_HOME entry in my environment variables. I added the following into my .profile (.zshrc in my case and also only adding a line for each version I have installed otherwise you will get errors);
|
|
Now if I want to switch between versions while on the terminal its a matter of typing java and the version number - java11, java12 etc.
|
|