oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Installing Tomcat on Mac OS X

by Dave Sag

Tomcat is a high-quality, Java-based server. The latest version, Tomcat 4.1, implements Sun Microsystems' Servlet 2.3 and Java ServerPages 1.2 specifications. The code for the original Tomcat was donated by Sun to the Apache project and since then has been completely rewritten.

If you're developing Web applications, or Web services, chances are you'll soon consider using a Tomcat 4.x server. Fortunately, this process is fairly painless if Mac OS X is your platform of choice.

This article walks you through the installation I use to develop and demonstrate Web applications and Web services on my PowerBook G4. I've installed Tomcat so that it loads at startup and runs without having to log in. This setup, along with some port forwarding, means that I can serve live client demonstrations from my laptop at home to clients in other countries.

There are a few flavors of Tomcat, which have been released from a number of sources, so you may end up with a few different installs. I develop Web services as well as traditional Web applications, so I installed the Tomcat that comes with the Java WebServices pack.

The Tomcat that comes with the Java WebServices pack is a simple install that gives me all the bits I need, including a special bunch of Ant tasks that use Tomcat's Manager application to perform temporary installs and removes the .war file without the need to restart. Even though this is an early access release, this version is stable enough for developing and includes the following:

  • Java XML Pack, which includes the following:
    • Java API for XML Messaging (JAXM) 1.0.1 EA2
    • Java API for XML Processing (JAXP) 1.2 EA2 (with XML Schema support)
    • Java API for XML Registries (JAXR) 1.0 EA2
    • Java API for XML-based RPC (JAX-RPC) 1.0 EA2
  • JavaServer PagesTM Standard Tag Library (JSTL) 1.0 Beta 1
  • Ant Build Tool 1.4.1
  • Java WSDP Registry Server 1.0 EA2
  • Web Application Deployment Tool
  • Apache Tomcat 4.1-dev Container

Go to Then select the Unix install and agree to the terms.

There is something weird about the way Sun sends files to Macintosh users, so the file you download will probably be named Document5. So, after the file has downloaded you must rename it to, or anything that ends in .sh.

Now It's Time to Set Up Your Mac

First, make some new folders in your /Library folder. Some people prefer to install things in their local ~/Library folder, but we want our Tomcat to start up before we log in, so /Library is a more appropriate place.

If there isn't already one, make a folder called StartupItems/, and next to it make one called Tomcat/. Then copy the into /Library/Tomcat.

You should be able to do this from the Finder. The folders you create will stay owned by you, and that's fine. You may want to change the those folders' permissions at some stage, but for now just leave them as they are. Some people like to create a special user for Tomcat, but that is overkill.

Unix commands you'll learn to love

l lists everything in that folder
cd path change directory to path
chmod 777 path changes permissions to world read/write and executable.
ln -s target source make soft link to target called source

Using the terminal cd into /Library/Tomcat and type

chmod 777

so that you can execute the installer file. You will probably delete this file later so don't be concerned about the permissions.


This launches the installer application. Click "approve" and "next" a few times. It will ask you if the default java1.3.1 home is OK. It should be fine. If you hit any problems here then Java 1.3.1 is probably stuffed. All Mac OS X installs have Java 1.3 or better.

Try typing java -version to see what version of Java you are running.

Next the installer will ask you for a username and a password. This will be the username and password that Tomcat requests when you administer it using the built-in manager tools. Remember it.

Pages: 1, 2

Next Pagearrow