I'm installing java8 and tomcat9 like this:
brew install adoptopenjdk/openjdk/adoptopenjdk8 --cask
ln -s $(/usr/libexec/java_home -v 1.8) /opt/homebrew/opt/openjdk
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)' >> ~/.zshrc
brew install tomcat@9 --ignore-dependencies
brew services start tomcat@9
I export the location of java to a environmentan variable called JAVA_HOME
stored in my user ~/.zshrc
file because catalina.sh needs the environmentan variable JAVA_HOME
setted to work.
If i start catalina.sh using terminal, works perfectly, but
brew services start tomcat@9
doesn't work because the launchctl service ignores the environmentan variable called JAVA_HOME
stored in my user ~/.zshrc
file. So it is ignoring the ~/.zshrc
file.
In Mac OSX Catalina
this worked perfectly, but it's failing in Monterey
This worked for me on Monterey:
See this answer if you want it to persist across reboots, not an issue for me as I rarely reboot and prefer to start Tomcat manually.