Sometimes you’ll come across applications that will require a specific version of Java. This will be because other versions of Java will have extra libraries that may not be compatible.
To install a specific version of Java on Mac OSX with homebrew, go to Github AdoptOpen JDK to see what version you need.
The basic command though will be to tap the AdoptOpenJDK repository with:
> brew tap AdoptOpenJDK/openjdk
> brew cast install <version>
Once it is installed, run
> java -version
to confirm that Java installed successfully. You should get the following:
15-MacBook-Pro:~ sean$ java -version openjdk version "1.8.0_242" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode) Note, to install the latest version, all you need to do is run:
> brew cast install adoptopenjdk
And if you are wondering what the difference is between a JDK and the JRE (the article prefix should be a clue), a Java Development Kit contains the Java Runtime Environment but also has javac (the compiler) along with other programming tools added. The Java Runtime Environment contains the Java Virtual Machine is which required to run Java programs.