O'Reilly logo

Tomcat: The Definitive Guide, 2nd Edition by Ian F. Darwin, Jason Brittain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A. Installing Java

There are several Java Software Development Kits (SDKs) available that will support Tomcat, depending on which operating system you run. To run Tomcat, you need a Java Standard Edition (Java SE), also known as the JDK. See Sun's J2SE home page for more information about what the Java SE includes at http://java.sun.com/javase.

We tried the following Java SE JDKs: Sun's HotSpot, IBM's J9, BEA's JRockit, Apple's Java SE for OS X, Excelsior's JET, and Apache's Harmony. Choose a JDK and then read and follow the installation documentation for the one you chose.

For Tomcat to use a JDK, you just need to make sure that the JAVA_HOME and PATH environment variables are set appropriately. JAVA_HOME must be set to the full path to the root directory of your JDK, and PATH must be set so that the first java executable found on PATH is the one you want to run. For example:

$ JAVA_HOME=/usr/java/jdk1.6.0_02
$ export JAVA_HOME
$ PATH=$JAVA_HOME/bin:$PATH
$ export PATH

The trick here is that the JAVA_HOME/bin path must precede any other paths that could contain a java binary.

Then, test your JDK so that you know the correct one will be used, like this:

$ java -version

Operating systems now often come with older or even incompatible Java runtimes that are either out-of-date or cannot successfully run all Java code. If you don't check, it's easy to inadvertently set up Tomcat to be run by the wrong Java runtime. Making sure that JAVA_HOME and PATH are correctly set to the JDK you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required