######## 7. download and run tomcat in the local development env ##############
# install brew (https://brew.sh/)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# install java
brew cask install adoptopenjdk
brew tap AdoptOpenJDK/openjdk
# Alert! don’t use the latest jdk, scala and sbt works on JDK 8
brew cask install adoptopenjdk8 
mkdir $HOME/tomcat; cd $HOME/tomcat #prepare a dir for Tomcat
# download tomcat tar ball
curl -fLO https://mirror.olnevhost.net/pub/apache/tomcat/tomcat-9/v9.0.38/bin/apache-tomcat-9.0.38.tar.gz #download the file
ls -ltrah #check that the file exists
tar -zxvf apache-tomcat-9.0.38.tar.gz #extract the file 
# java is not in your path then
vi $HOME/.bash_profile #modify the basf profile with JAVA_HOME
# add the below line to your profile (adjust the jdk path to your installed directory)
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/
source $HOME/.bash_profile #update your current env or you could relogin
echo $JAVA_HOME
$JAVA_HOME/bin/java -version #check that 'java' works
cd $HOME/tomcat/apache-tomcat-9.0.38/bin/ 
./startup.sh #start tomcat
curl localhost:8080 #check that tomcat works
./shutdown.sh #shutdown tomcat
curl localhost:8080 #you should get a Connection refused error