eclipse远程调试两种模式:

 eclipse远程调试两种模式:
一、服务端监听
(1)服务器端需执行程序前加参数  -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
   说明:server=y 是指目标应用程序作为服务监听将要连接的远程调试器(常用);
         suspend=y 是指目标VM将暂停,直到调试器应用程序进行连接(若需要调试启动错误,很有用);
         suspend=n 是指目标VM不暂停;
         address=8000 监听端口。
(2)运行服务端程序,程序将暂停
(3)eclipse ==> Debug Configurations ==> Remote Java Application 新建测试工程
(4)选择工程 ==> 模式 Socket Attach ==>  调试服务器IP ==> 调试端口(这里假设8000)
(5)运行debug

二、调试端监听(不常用)
(1)eclipse ==> Debug Configurations ==> Remote Java Application 新建测试工程
(2)选择工程 ==> 模式 Socket Listen ==> 调试监听端口(这里假设8000) ==> Allow termination of remote VM 打勾
(3)运行debug,程序将暂停,左上显示 Waiting for vm to connect at port 8000...
(4)服务器端需执行程序前加参数  -Xdebug -Xrunjdwp:transport=dt_socket,address=172.16.7.34:8000
   说明:address=172.16.7.34:8000 发送连接的地址和端口。

(5)运行服务端程序

转自: http://hi.baidu.com/sohochaser/blog/item/250ea38be7923c659e2fb40a.html
 
参考资料: http://www.ibm.com/developerworks/cn/opensource/os-eclipse-javadebug/
 

jpda.bat的完整内容列在下面,其中黑体部分,在startup.bat基础上添加的代码:

@echo off
if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem Jpda script for the CATALINA Server
rem
rem $Id: jpda.bat 302918 2004-05-27 18:25:11Z yoavs $
rem ---------------------------------------------------------------------------

rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%CURRENT_DIR%
if exist "%CATALINA_HOME%/bin/catalina.bat" goto okHome
cd ..
set CATALINA_HOME=%cd%
cd %CURRENT_DIR%
:gotHome
if exist "%CATALINA_HOME%/bin/catalina.bat" goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome

set EXECUTABLE=%CATALINA_HOME%/bin/catalina.bat

rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find %EXECUTABLE%
echo This file is needed to run this program
goto end
:okExec

rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=8000
set JPDA_SUSPEND=y


call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

你可能感兴趣的:(eclipse远程调试两种模式:)