Installing Tomcat from Source

If you want to obtain the latest version of Tomcat with the newest bug fixes and upgrades, then installing it from the source code is a good option. In Linux it’s far more common for servers to be built for the system. However, this isn’t strictly necessary for a Java-based server such as Tomcat.

Tomcat is easily built using the Ant build utility. You use Ant for automated project building, including compilation and deployment. It has all the system-independent benefits that Java enjoys because it’s written in Java.

You can also use Ant to carry out a number of administrative actions on Tomcat, each of which is described in Chapter 6. The deployer application mentioned previously also uses Ant.

It used to be the case that you had to manually download a huge number of libraries from many different sources to compile Tomcat, but now Ant can do it for you. In fact, it will even download the Tomcat’s source for you.

All you need to download and build Tomcat is the http://jakarta.apache.org/tomcat/tomcat-5.0-doc/build.xml file (or http://jakarta.apache.org/tomcat/tomcat-5.5-doc/build.xml) and a file called build.properties that you create for the purpose. Download the build.xml file to a convenient directory where you’ll carry out the build. Create a build.properties file in the same directory with the appropriate lines from Listing 2-1. Those with # marks are commented out and can be ignored if they don’t apply to your installation. You should ensure that base.path points to the place you want to download.

Listing 2-1: Ant’s build.properties File

image from book
 # ----- Default Base Path for Dependent Packages ----- # ----- Linux/Unix path ----- base.path=/usr/share/java  # ----- Windows path ----- #base.path=C://TomcatBuild  # ----- Proxy setup ----- # Uncomment if using a proxy server  #proxy.host=proxy.domain  #proxy.port=8080  #proxy.use=on 
image from book

Once you’re satisfied with your setup, you can build Tomcat using the following line in the base directory:

 > ant 

The build will take a few minutes, and the resultant build is the subdirectory jakarta-tomcat-5/build. To deploy the new server, move (and rename) it out of the source folder and into a folder of its own, and set the CATALINA_HOME variable using the instructions given previously.

If you want to update the source code and recompile it, use the following commands in the source directory:

 > ant checkout  > ant build 

The second command will compile only those files that have changed, so you can also use it to compile the server if you’ve made any changes of your own to the source.



Pro Jakarta Tomcat 5
Pro Apache Tomcat 5/5.5 (Experts Voice in Java)
ISBN: 1590593316
EAN: 2147483647
Year: 2004
Pages: 94

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net