Statement: Recently in the study of Tomcat6 source code, online search for some relevant information, and the operation of their own under the corresponding summary. Now summary for example the following
Purpose of this article: Compile TOMCAT6 Source code + import Tomcat6 source code to MyEclipse
Test environment:
Jdk:jdk1.7.0_80
Axis:axis-bin-1_4
ant:apache-ant-1.9.2
myeclipse:2015
tomcat:apache-tomcat-6.0.45
Steps:
One: Download Tomcat's source code package
This can be downloaded via SVN or directly to the Tomcat website, which I downloaded directly to the website.
Here I am using src not the tar version number.
The source code package is then extracted to the specified directory.
My extract to this folder, it is important to note that the output folder is generated at compile time. Build.properties was renamed after me, this file was originally a Build.properties.default file.
Tomcat is compiled by default with Ant, and people familiar with ant should know how to fix it by configuring file build.properties . The configuration file is "Build.properties.default" under the Tomcat source code path, and we can remove the. default suffix or create a new build.properties directly, and of course I chose the former, will " Build.properties.default "Change to" build.properties "open, change the value of the Base.path property is the desired download path and add Proxy agent configuration (I just changed the path of the download is to execute ant The path that is downloaded when the download command. The proxy is not set), such as the following format:
II: Ant's Installation
Here can participate in the introduction of the online, I just about the next step here
2.1 First to download Ant's Zip package on the website first. Then unzip
2.2 Configuring Environment variables
2.3 Verifying whether the installation was successful
Three: Tomcat's compilation
during the Tomcat compilation process, Ant will let us download some of the necessary dependencies, and the Base.path folder is used to save the project files. We've already configured this in the first step. After we have changed Base.path , we return to MS-DOS form. Switch to the folder where Tomcat source is located, and then execute the ant download command, for example, as seen in:
I am more successful here, the first time the execution of the report error, is connection timeout error. The reason is that the connection timed out, and I once again executed the ant download command successfully.
At this time you can see that Base.path has more folders in the specified folder. Ant download command succeeds after running ant command
I have a partial warning here, just to be able to run successfully. To this place Tomcat's source code was compiled successfully.
Report:
① assume that you have changed some of the source code, need to compile again, directly into the source code path. You can run the ant command.
② assumes that you need to compile the servlet and JSP API documentation to run under the source code path, such as the following command:
Ant-f Dist.xmldist-javadoc
③ assumes the need to compile extras extension functions (commons-logging,webservices etc). Go to the source code path to run the following command, for example:
Ant-f Extras.xml
④ assumes that the release version number must be compiled. Go to the source code path to run the following command, for example:
Ant-f Dist.xmlrelease
Four: import Tomcat to MyEclipse
4.1 Open MyEclipse New Javaproject
Initially there was only the SRC directory and the JRE System Library (I used the jdk1.7 to return the error when starting with 1.6 later, this is a detailed look at the version number match)
4.2javaproject when new is complete, select Javaproject.
Import->file system
Select the tomcat source code from directory, choose Java and Test (if you need to test, choose Test). For example, with:
Select our newly-created tomcat6,finish in into folder.
Note: Set Java, test to source folder. Java Build path->source->addfolder...-> select Java and test.
Now the project structure, for example, is seen
4.3 Importing jar Packages
The bad red forks above are due to the lack of jars, and we need those jar packs now?
Test needs to be junit.jar. This can be used directly from eclipse. I was taken from the JUnit saved in the first step
In Java, you need:
· Ant.jar This can be obtained from the downloaded ant
· Jaxrpc.jar This can be obtained from AIX2 's package.
· Org.eclipse.jdt.core_3.3.1.v_780_r33x.jar This can be downloaded from ant download jdt.loc=http://www.eclipse.org/downloads/ Download.php?file=/eclipse/downloads/drops/r-3.3.1-200709211145/eclipse-jdt-3.3.1.zip This package to get
· Wsdl4j-1.5.1.jar This can be obtained from AIX2 's package.
It's refreshing after the import!
4.4 Starting Tomcat
Note that when I tested it, I found that it was not possible to configure the Tomcat plugin in the MyEclipse workspace.
Locate the class: Bootstrap class in the Org.apache.catalina.startup package.
Run as: Set in arguments VM arguments
-dcatalina.home= " E:\job\tomcatsrc\apache-tomcat-6.0.45-src\output\build"
And then you can start it!
The above path is based on your actual situation.
In the same vein, stop is configured to stop and run is available.
Compilation and import of Tomcat6 MyEclipse