Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
771 blopes 1
<!DOCTYPE html SYSTEM "about:legacy-compat">
2
<html lang="en"><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><link href="./images/docs-stylesheet.css" rel="stylesheet" type="text/css"><title>Apache Tomcat 9 (9.0.112) - Building Tomcat</title></head><body><div id="wrapper"><header><div id="header"><div><div><div class="logo noPrint"><a href="https://tomcat.apache.org/"><img alt="Tomcat Home" src="./images/tomcat.png"></a></div><div style="height: 1px;"></div><div class="asfLogo noPrint"><a href="https://www.apache.org/" target="_blank"><img src="./images/asf-logo.svg" alt="The Apache Software Foundation" style="width: 266px; height: 83px;"></a></div><h1>Apache Tomcat 9</h1><div class="versionInfo">
3
            Version 9.0.112,
4
            <time datetime="2025-11-06">Nov 6 2025</time></div><div style="height: 1px;"></div><div style="clear: left;"></div></div></div></div></header><div id="middle"><div><div id="mainLeft" class="noprint"><div><nav><div><h2>Links</h2><ul><li><a href="index.html">Docs Home</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/FAQ">FAQ</a></li></ul></div><div><h2>User Guide</h2><ul><li><a href="introduction.html">1) Introduction</a></li><li><a href="setup.html">2) Setup</a></li><li><a href="appdev/index.html">3) First webapp</a></li><li><a href="deployer-howto.html">4) Deployer</a></li><li><a href="manager-howto.html">5) Manager</a></li><li><a href="host-manager-howto.html">6) Host Manager</a></li><li><a href="realm-howto.html">7) Realms and AAA</a></li><li><a href="security-manager-howto.html">8) Security Manager</a></li><li><a href="jndi-resources-howto.html">9) JNDI Resources</a></li><li><a href="jndi-datasource-examples-howto.html">10) JDBC DataSources</a></li><li><a href="class-loader-howto.html">11) Classloading</a></li><li><a href="jasper-howto.html">12) JSPs</a></li><li><a href="ssl-howto.html">13) SSL/TLS</a></li><li><a href="ssi-howto.html">14) SSI</a></li><li><a href="cgi-howto.html">15) CGI</a></li><li><a href="proxy-howto.html">16) Proxy Support</a></li><li><a href="mbeans-descriptors-howto.html">17) MBeans Descriptors</a></li><li><a href="default-servlet.html">18) Default Servlet</a></li><li><a href="cluster-howto.html">19) Clustering</a></li><li><a href="balancer-howto.html">20) Load Balancer</a></li><li><a href="connectors.html">21) Connectors</a></li><li><a href="monitoring.html">22) Monitoring and Management</a></li><li><a href="logging.html">23) Logging</a></li><li><a href="apr.html">24) APR/Native</a></li><li><a href="virtual-hosting-howto.html">25) Virtual Hosting</a></li><li><a href="aio.html">26) Advanced IO</a></li><li><a href="maven-jars.html">27) Mavenized</a></li><li><a href="security-howto.html">28) Security Considerations</a></li><li><a href="windows-service-howto.html">29) Windows Service</a></li><li><a href="windows-auth-howto.html">30) Windows Authentication</a></li><li><a href="jdbc-pool.html">31) Tomcat's JDBC Pool</a></li><li><a href="web-socket-howto.html">32) WebSocket</a></li><li><a href="rewrite.html">33) Rewrite</a></li><li><a href="cdi.html">34) CDI 2 and JAX-RS</a></li><li><a href="graal.html">35) AOT/GraalVM Support</a></li></ul></div><div><h2>Reference</h2><ul><li><a href="RELEASE-NOTES.txt">Release Notes</a></li><li><a href="config/index.html">Configuration</a></li><li><a href="api/index.html">Tomcat Javadocs</a></li><li><a href="servletapi/index.html">Servlet 4.0 Javadocs</a></li><li><a href="jspapi/index.html">JSP 2.3 Javadocs</a></li><li><a href="elapi/index.html">EL 3.0 Javadocs</a></li><li><a href="websocketapi/index.html">WebSocket 1.1 Javadocs</a></li><li><a href="jaspicapi/index.html">JASPIC 1.1 Javadocs</a></li><li><a href="annotationapi/index.html">Common Annotations 1.3 Javadocs</a></li><li><a href="https://tomcat.apache.org/connectors-doc/">JK 1.2 Documentation</a></li></ul></div><div><h2>Apache Tomcat Development</h2><ul><li><a href="building.html">Building</a></li><li><a href="changelog.html">Changelog</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/Tomcat+Versions">Status</a></li><li><a href="developers.html">Developers</a></li><li><a href="architecture/index.html">Architecture</a></li><li><a href="tribes/introduction.html">Tribes</a></li></ul></div></nav></div></div><div id="mainRight"><div id="content"><h2>Building Tomcat</h2><h3 id="Table_of_Contents">Table of Contents</h3><div class="text">
5
<ul><li><a href="#Introduction">Introduction</a></li><li><a href="#Download_a_Java_Development_Kit_(JDK)">Download a Java Development Kit (JDK)</a></li><li><a href="#Install_Apache_Ant">Install Apache Ant</a></li><li><a href="#Obtain_the_Tomcat_source_code">Obtain the Tomcat source code</a></li><li><a href="#Configure_download_area">Configure download area</a></li><li><a href="#Building_Tomcat">Building Tomcat</a></li><li><a href="#Building_with_Eclipse">Building with Eclipse</a></li><li><a href="#Building_with_other_IDEs">Building with other IDEs</a></li></ul>
6
</div><h3 id="Introduction">Introduction</h3><div class="text">
7
 
8
<p>
9
Building Apache Tomcat from source is very easy, and is the first step to
10
contributing to Tomcat. The complete and comprehensive instructions are
11
provided in the file <a href="BUILDING.txt">BUILDING.txt</a>.
12
The following is a quick step by step guide.
13
</p>
14
 
15
</div><h3 id="Download_a_Java_Development_Kit_(JDK)">Download a Java Development Kit (JDK)</h3><div class="text">
16
 
17
<p>
18
Building Apache Tomcat requires a JDK (version 11) or later to be installed. You
19
can download one from
20
<a href="https://adoptium.net/temurin/releases">https://adoptium.net/temurin/releases</a>
21
or another JDK vendor.
22
</p>
23
 
24
<p>
25
<b>IMPORTANT</b>: Set an environment variable JAVA_HOME to the pathname of the
26
directory into which you installed the JDK release.
27
</p>
28
 
29
</div><h3 id="Install_Apache_Ant">Install Apache Ant</h3><div class="text">
30
 
31
<p>
32
Download a binary distribution of Ant 1.10.2 or later from
33
<a href="https://ant.apache.org/bindownload.cgi">here</a>.
34
</p>
35
 
36
<p>
37
Unpack the binary distribution into a convenient location so that the
38
Ant release resides in its own directory (conventionally named
39
<code>apache-ant-[version]</code>).  For the remainder of this guide,
40
the symbolic name <code>${ant.home}</code> is used to refer to the full pathname of
41
 the Ant installation directory.
42
</p>
43
 
44
<p>
45
<b>IMPORTANT</b>: Create an ANT_HOME environment variable to point the directory <code>${ant.home}</code>,
46
and modify the PATH environment variable to include directory
47
<code>${ant.home}/bin</code> in its list.  This makes the <code>ant</code> command line script
48
available, which will be used to actually perform the build.
49
</p>
50
 
51
</div><h3 id="Obtain_the_Tomcat_source_code">Obtain the Tomcat source code</h3><div class="text">
52
 
53
  <p>
54
  Tomcat Git repository URL:
55
  <a href="https://github.com/apache/tomcat">https://github.com/apache/tomcat</a>
56
  </p>
57
  <p>
58
  Tomcat source packages:
59
  <a href="https://tomcat.apache.org/download-90.cgi">https://tomcat.apache.org/download-90.cgi</a>.
60
  </p>
61
 
62
  <p>
63
  Clone the source repository using Git, selecting a tag for released version or
64
  9.0.x for the current development code, or download and unpack a
65
  source package. For the remainder of this guide, the symbolic name
66
  <code>${tomcat.source}</code> is used to refer to the
67
  location where the source has been placed.
68
  </p>
69
 
70
</div><h3 id="Configure_download_area">Configure download area</h3><div class="text">
71
 
72
<p>
73
  Building Tomcat involves downloading a number of libraries that it depends on.
74
  It is strongly recommended to configure download area for those libraries.
75
</p>
76
 
77
<p>
78
  By default the build is configured to download the dependencies into the
79
  <code>${user.home}/tomcat-build-libs</code> directory. You can change this
80
  (see below) but it must be an absolute path.
81
</p>
82
 
83
<p>
84
  The build is controlled by creating a
85
  <code>${tomcat.source}/build.properties</code> file. It can be used to
86
  redefine any property that is present in <code>build.properties.default</code>
87
  and <code>build.xml</code> files. The <code>build.properties</code> file
88
  does not exist by default. You have to create it.
89
</p>
90
 
91
<p>
92
  The download area is defined by property <code>base.path</code>. For example:
93
</p>
94
 
95
<div class="codeBox"><pre><code># ----- Default Base Path for Dependent Packages -----
96
# Replace this path with the directory path where
97
# dependencies binaries should be downloaded.
98
base.path=/home/me/some-place-to-download-to</code></pre></div>
99
 
100
<p>
101
  Different versions of Tomcat are allowed to share the same download area.
102
</p>
103
 
104
<p>
105
  Another example:
106
</p>
107
 
108
<div class="codeBox"><pre><code>base.path=${user.dir}/../libraries-tomcat9.0</code></pre></div>
109
 
110
<p>
111
  Users who access the Internet through a proxy must use the properties
112
  file to indicate to Ant the proxy configuration:
113
</p>
114
 
115
<div class="codeBox"><pre><code># ----- Proxy setup -----
116
proxy.host=proxy.domain
117
proxy.port=8080
118
proxy.use=on</code></pre></div>
119
 
120
</div><h3 id="Building_Tomcat">Building Tomcat</h3><div class="text">
121
 
122
<p>
123
Use the following commands to build Tomcat:
124
</p>
125
 
126
<p>
127
<code>cd ${tomcat.source}</code><br>
128
<code>ant</code>
129
</p>
130
 
131
<p>
132
Once the build has completed successfully, a usable Tomcat installation will have been
133
produced in the <code>${tomcat.source}/output/build</code> directory, and can be started
134
and stopped with the usual scripts.
135
</p>
136
</div><h3 id="Building_with_Eclipse">Building with Eclipse</h3><div class="text">
137
 
138
<p>
139
<b>IMPORTANT:</b> This is not a supported means of building Tomcat; this information is
140
provided without warranty :-).
141
The only supported means of building Tomcat is with the Ant build described above.
142
However, some developers like to work on Java code with a Java IDE,
143
and the following steps have been used by some developers.
144
</p>
145
 
146
<p>
147
<b>NOTE:</b> This will not let you build everything under Eclipse;
148
the build process requires use of Ant for the many stages that aren't
149
simple Java compilations.
150
However, it will allow you to view and edit the Java code,
151
get warnings, reformat code, perform refactorings, run Tomcat
152
under the IDE, and so on.
153
</p>
154
 
155
<p>
156
<b>WARNING:</b> Do not forget to create and configure
157
  <code>${tomcat.source}/build.properties</code> file as described above
158
  before running any Ant targets.
159
</p>
160
 
161
<p>
162
Sample Eclipse project files and launch targets are provided in the
163
<code>res/ide-support/eclipse</code> directory of the source tree.
164
The instructions below will automatically copy these into the required locations.
165
</p>
166
<p>
167
An Ant target is provided as a convenience to download all binary dependencies, and to create
168
the Eclipse project and classpath files in the root of the source tree.
169
</p>
170
 
171
<p>
172
<code>cd ${tomcat.source}</code><br>
173
<code>ant ide-eclipse</code>
174
</p>
175
 
176
<p>
177
Start Eclipse and create a new Workspace.
178
</p>
179
 
180
<p>
181
Use <em>File-&gt;Import</em> and choose <em>Existing Projects into Workspace</em>.
182
From there choose the root directory of the Tomcat source tree (<code>${tomcat.source}</code>)
183
and import the Tomcat project located there.
184
</p>
185
 
186
<p>
187
<code>start-tomcat</code> and <code>stop-tomcat</code> launch configurations are provided in
188
<code>res/ide-support/eclipse</code> and will be available in the <em>Run-&gt;Run Configurations</em>
189
dialog. Use these to start and stop Tomcat from Eclipse.
190
If you want to configure these yourself (or are using a different IDE)
191
then use <code>org.apache.catalina.startup.Bootstrap</code> as the main class,
192
<code>start</code>/<code>stop</code> etc. as program arguments, and specify <code>-Dcatalina.home=...</code>
193
(with the name of your build directory) as VM arguments.
194
</p>
195
 
196
<p>
197
Tweaking a few formatting preferences will make it much easier to keep consistent with Tomcat
198
coding conventions (and have your contributions accepted):
199
</p>
200
 
201
<table class="defaultTable">
202
  <tr><td>Java -&gt; Code Style -&gt; Formatter -&gt; Edit...</td>
203
  <td>Tab policy: Spaces only<br>Tab and Indentation size: 4</td></tr>
204
  <tr><td>General -&gt; Editors -&gt; Text Editors</td>
205
  <td>Displayed tab width: 2<br>Insert spaces for tabs<br>Show whitespace characters (optional)</td></tr>
206
  <tr><td>XML -&gt; XML Files -&gt; Editor</td><td>Indent using spaces<br>Indentation size: 2</td></tr>
207
  <tr><td>Ant -&gt; Editor -&gt; Formatter</td><td>Tab size: 2<br>Use tab character instead of spaces: unchecked</td></tr>
208
</table>
209
 
210
<p>
211
The recommended configuration of Compiler Warnings is documented in
212
<code>res/ide-support/eclipse/java-compiler-errors-warnings.txt</code> file.
213
</p>
214
 
215
</div><h3 id="Building_with_other_IDEs">Building with other IDEs</h3><div class="text">
216
<p>
217
The same general approach should work for most IDEs; it has been reported
218
to work in IntelliJ IDEA, for example.
219
</p>
220
 
221
</div></div></div></div></div><footer><div id="footer">
222
    Copyright &copy; 1999-2025, The Apache Software Foundation
223
    <br>
224
    Apache Tomcat, Tomcat, Apache, the Apache Tomcat logo and the Apache logo
225
    are either registered trademarks or trademarks of the Apache Software
226
    Foundation.
227
    </div></footer></div></body></html>