首先需要下载tomcat的源码,然后创建一个java project 导入tomcat源代码
像下图:到如下层级:C:\Users\Administrator\Downloads\apache-tomcat-7.0.47-src\apache-tomcat-7.0.47-src\java
然后修改tomcat/bin/startup.bat
添加如下:suspend=y 就可以调试tomcat启动过程。
SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8788
打开你想调试的tomcat源码:
eclipse
然后启动就可以看见调试的代码了。
import java.util.Enumeration;
import org.apache.commons.compress.archivers.jar.JarArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
public class ZipDemo {
public static void main(String[] args) throws Exception {
//use apache commons-commpress for zip...
String file = "C:\\Users\\Administrator\\Downloads\\apache-tomcat-7.0.54\\中文apache-tomcat-7.0.54\\lib\\annotations-api.jar";
String file2 ="jar:file:/C:/Users/Administrator/Downloads/apache-tomcat-7.0.54/中文apache-tomcat-7.0.54/webapps/examples/WEB-INF/lib/poi-contrib-3.2-FINAL-20081019.jar!/";
System.out.println(file2.substring(10));
ZipFile zf = new ZipFile(file2, "utf-8");
Enumeration e = zf.getEntries();
while(e.hasMoreElements())
{
System.out.println(e.nextElement());
}
zf.closeQuietly(zf);
// en = new JarArchiveEntry(file);
// en.get
}
}