Unable to find any JVMs matching version "1.8.0_40" when open terminal on macOS

MacOS X does not come with Java Development Kits (JDKs) pre-installed. Run java -version in the terminal and you may be prompted to install Java. Unless you already have JVM installed, in which case you will see the build version number.

Next, you will be prompted to visit the Java SE Development Kit Downloads page. Download one of the JDK (Java Development Kits) with a file extension ending in <filename>.tar.gz.

Then run tar -xf <filename>.tar.gz.

Rename the newly created directory to JAVA_HOME.


i solved this using this command in terminal

brew install --cask homebrew/cask-versions/adoptopenjdk8