Update brew:

brew update

Tap de formula repository cask-versions:

brew tap homebrew/cask-versions

Install Java:

brew cask install java

The problem though is that we’ll get the last version, in my case 13.0.1, check it executing this:

/usr/libexec/java_home -V

To get version 1.8 execute:

brew cask install adoptopenjdk8

Add the following export to the .bash_profile or .zshrc:

export JAVA_HOME="`/usr/libexec/java_home -v 1.8`"

To ease changing between Java versions we can define also this function:

function setjdk() {
  export JAVA_HOME=`/usr/libexec/java_home -v $@`
}

Finally we’ll install Scala and SBT:

brew install scala sbt

If you are using IntelliJ set /usr/local/opt/scala/idea as home.

To modifiy global settings edit /usr/local/etc/sbtopts file.