Installing Tomcat on macOS 12 Monterey

The Servlet 5.0 specification is out and Tomcat 10.0.x does support it. Time to dive into Tomcat 10.

Prerequisite: Java

Tomcat 10 requires Java version 8 or later and since OS X 10.7 Java is not (pre-)installed anymore. Let’s fix that by installing a Prebuilt OpenJDK Binary. Easy to follow details about how to install OpenJDK are available here. Anyway, after opening the Terminal app,
java --version
hopefully shows something like this:

openjdk 17.0.3 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)

Whatever you do, when opening Terminal and running ‘java –version’, you should see something like this, with a version of at least 1.8.x Again, Tomcat 10.0.x requires Java 8 or later.

sudo
sudo is a program for Unix-like operating systems, allowing you to run programs with the security privileges of another user (normally the superuser, or root). Since we are creating directories, outside of your home folder, administrator right are required. I.e., when executing sudo you will be asked to enter your password; and your Mac User account needs to be an ‘Admin’ account.

JAVA_HOME is an important environment variable, not just for Tomcat, and it’s important to get it right. Here is a trick that allows me to keep the environment variable current, even after a Java Update was installed. In ~/.zshenv, I set the variable like so:

export JAVA_HOME=$(/usr/libexec/java_home)

Installing Tomcat

Here are the easy to follow steps to get it up and running on your Mac

  1. Download a binary distribution of the core module: apache-tomcat-10.0.21 from here. I picked the tar.gz in Binary Distributions Core section.
  2. Opening/unarchiving the archive will create a new folder structure in your Downloads folder: (btw, this free Unarchiver app is perfect for all kinds of compressed files and superior to the built-in Archive Utility.app)
    ~/Downloads/apache-tomcat-10.0.21
  3. Open the Terminal app to move the unarchived distribution to /usr/local like so:
    sudo mkdir -p /usr/local
    sudo mv ~/Downloads/apache-tomcat-10.0.21 /usr/local
  4. To make it easy to replace this release with future releases, we are going to create a symbolic link that we are going to use when referring to Tomcat (after removing the old link, you might have from installing a previous version):
    sudo rm -f /Library/Tomcat
    sudo ln -s /usr/local/apache-tomcat-10.0.21 /Library/Tomcat
  5. Change ownership of the /Library/Tomcat folder hierarchy:
    sudo chown -R <your_username> /Library/Tomcat
  6. Make all scripts in Tomcat’s ./bin folder executable:
    sudo chmod +x /Library/Tomcat/bin/*.sh

Tomcat 10.0.x

Starting Tomcat by executing the provided scripts, like so:
/Library/Tomcat/bin/startup.sh

Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.

Finally, after your started Tomcat, open your Mac’s Web browser and take a look at the default page: http://localhost:8080

Tomcat 10.0.x

 

Stopping Tomcat by executing the provided scripts, like so:

/Library/Tomcat/bin/shutdown.sh

 

 

22 Replies to “Installing Tomcat on macOS 12 Monterey”

  1. Great tutorial and works brilliantly!

  2. Does installing Tomcat controller work for you? I download the DMG and I cant open it…

    1. I guess the Tomcat controller was never updated to 64 bit

  3. Worked great, thank you so much!

  4. this was helpful! Thanks for clear and concise guide.

  5. Yep, It has worked!
    Thank you!!!

  6. Cameron young says: Reply

    On the section ‘Change ownership of the /Library/Tomcat folder hierarchy:
    sudo chown -R /Library/Tomcat’

    I enter my username which is and I get zsh: no such file or directory: cameronyoung response. Not sure if anyone knows why?

  7. Worked on my Macbook Air M1 late 2020.
    Thanks

    1. Nhaniso Undenge says: Reply

      U must write the username without including the symbols

  8. Yeah nice one.

    Coming from homebrew as a ruby dev this is (a bit) excruciating 🙂 but you made it relatively simple.

    Looking forward to being productive and contributing to the java SDK project I am working on.

  9. Downloaded then zip on my mac and works like a charm. thx

  10. how to find tomcat username or password i try admin admin but not responce??

  11. Great. Thanks

  12. thank you mate! brilliant

  13. Worked as expected, thank you

  14. Helpful, thanks! It’s obnoxious how many articles I read before finding something that worked

  15. Thanks for the tutorial. Precise and works brilliantly.

  16. For once, a tutorial works directly without adaptation.
    A big thank you

  17. Great tutorial, Thanks! Very clear and fast

  18. After following the steps in this guide, how do I UNINSTALL the tomcat installed following these steps?

    1. https://wolfpaulus.com/tomcat/ has instruction about uninstalling Tomcat

Leave a Reply to Chris Cancel reply