The Servlet 4.0 requirement is out and Tomcat 9.0.x does support it. It’s time to jump into Tomcat 9.
Since OS X 10.7 Java is not (pre-)installed anymore, let’s fix that first. As I’m writing this, Java 1.8.0_111 is the latest version.
The JDK installer package comes in a dmg and installs simply on the Mac; and after opening the Terminal app again and type the below command to see the Java Version
After running the above command, now that shows something like below:
java version “1.8.0_111”
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
Whatever you do, when opening Terminal and running ‘java -version’, you should see somewhat like this, with a version of at least 1.8.x I.e. and Tomcat 9.x requires Java 8 or later.
sudo is a program for Unix-like operating systems, which is allowing you to run programs with the security rights of another user (it is normally the superuser, or root). Since we are creating directories, separate of your home folder, administrator right is 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 the main 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 ~/.bash_profile, I set the variable like so:
Installing Tomcat on Mac System
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-9.0.0.M15.tar.gz. 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)
3. Open to Terminal app to move the unarchived distribution to /usr/local
sudo mkdir -p /usr/local
sudo mv ~/Downloads/apache-tomcat-9.0.0.M15 /usr/local
4. To make it easy to replace this release with future releases, I am going to create a symbolic link that I am 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-9.0.0.M15 /Library/Tomcat
5. Change ownership of the /Library/Tomcat folder hierarchy:
sudo chown -R /Library/Tomcat
6. Make all scripts executable:
sudo chmod +x /Library/Tomcat/bin/*.sh
Instead of using the start and stop scripts, like so:
you may also need to check out Activata’s Tomcat Controller, a tiny freeware app, providing a UI to quickly start/stop Tomcat. It may not say so, but Tomcat Controller works on macOS 10.12 just fine.
Finally, after your started Tomcat, open your Mac’s Web browser and take a look at the default page: http://localhost:8080