原文地址:http://blog.csdn.net/lishengc/article/details/6615826
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 offif "%OS%" == "Windows_NT" setlocalrem ---------------------------------------------------------------------------rem Jpda script for the CATALINA Serverremrem $Id: jpda.bat 302918 2004-05-27 18:25:11Z yoavs $rem ---------------------------------------------------------------------------rem Guess CATALINA_HOME if not definedset CURRENT_DIR=%cd%if not "%CATALINA_HOME%" == "" goto gotHomeset CATALINA_HOME=%CURRENT_DIR%if exist "%CATALINA_HOME%/bin/catalina.bat" goto okHomecd ..set CATALINA_HOME=%cd%cd %CURRENT_DIR%:gotHomeif exist "%CATALINA_HOME%/bin/catalina.bat" goto okHomeecho The CATALINA_HOME environment variable is not defined correctlyecho This environment variable is needed to run this PRogramgoto end:okHomeset EXECUTABLE=%CATALINA_HOME%/bin/catalina.batrem Check that target executable existsif exist "%EXECUTABLE%" goto okExececho Cannot find %EXECUTABLE%echo This file is needed to run this programgoto end:okExecrem Get remaining unshifted command line arguments and save them in theset CMD_LINE_ARGS=:setArgsif ""%1""=="""" goto doneSetArgsset CMD_LINE_ARGS=%CMD_LINE_ARGS% %1shiftgoto setArgs:doneSetArgsset JPDA_TRANSPORT=dt_socketset JPDA_ADDRESS=8000set JPDA_SUSPEND=y call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
新聞熱點
疑難解答