First we need to load/run the application in remote debug mode:
-------------------------------------------------------------------------------------------------------------------
For a normal Java application loading & running(set a command line script for loading):
------------------
SET CP=D:/work/ReverseTest/TestClass/bin
java -cp %CP% -agentlib:jdwp=transport=dt_socket,address=localhost:8888,server=y,suspend=y TestClass
------------------
Or config like following:
------------------
SET CP=D:/work/ReverseTest/TestClass/bin
java -cp %CP% -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=localhost:8888 TestClass
------------------
For a tomcat or Jboss, weblogic server, please set the following options in its loading shell script.
JBOSS:
Change run.bat/run.sh under JBOSS_HOME/bin(add the red line as following):
JBOSS_HOME: /var/jboss4
JAVA: /usr/java/j2sdk1.4.2_06/bin/java
JAVA_OPTS: -server -Xms128m -Xmx128m -Dprogram.name=run.sh
DEBUG_OPTS = -Xdebug -Xrunjdwp:transport= dt_socket,address=localhost:8888,server=y,suspend=n
CLASSPATH: /var/jboss4/bin/run.jar:/usr/java/j2sdk1.4.2_06/lib/tools.jar
TOMCAT:
Change catalina.bat/catalina.sh under TOMCAT_HOME/bin.(add the red line as following)
DEBUG_OPTS = -Xdebug -Xrunjdwp:transport= dt_socket,address=localhost:8888,server=y,suspend=n
Second we need to config our Eclipse tool to do the remote debug operation:
-------------------------------------------------------------------------------------------------------------------
1. Create a project by using the existed source code:
2. Click on the project(right mouse), select "Debug As"->"Debug Configurations…".

3. On the "Debug Configurations" page, click right mouse on the "Remote Java Application"->"New".

4. Fill the configuration page like the following, then click "Apply", set "breakpoints" and then start debug process by clicking "Debug".

5. On the running page, you can see the following screen.

本文介绍如何设置Java应用程序以便进行远程调试,包括配置JBoss、Tomcat等服务器,并使用Eclipse进行远程调试操作。
1567

被折叠的 条评论
为什么被折叠?



