http://www.ibm.com/developerworks/cn/opensource/os-eclipse-javadebug/
1.用eclipse将工程打为可以运行的jar包
2.在控制台输入命令,hello.jar为jar包名称
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address="8000" -jar hello.jar
3.在eclipse设置断点,run--Debug Configurations,打开调试对话框,Host里输入远程ip地址,Port为address里配置端口,点debug进行调试
eclipse远程调试tomcat应用
1.将应用打成war包,部署到tomcat里
windows平台,编辑bin/catalina.bat,在开头加入,8000为调试端口,有冲突改成其他端口
set CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE - Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
2.Linux平台,用vi或gedit编辑bin/startup.sh文件,
将文件最后exec "$PRGDIR"/"$EXECUTABLE" start "$@"改成
exec "$PRGDIR"/"$EXECUTABLE" jpda start"$@"
注意有空格
3.在eclipse里run--debug configurations选项,找到remote applications,右击,新建应用,输入ip和port,勾上Allow terminaion of remote VM,进行调试