1. 程式人生 > >Eclipse遠端除錯jar包

Eclipse遠端除錯jar包

普通Java程式:

1、匯出包括除錯資訊的jar工程

在eclipse中,選擇 Window > Preferences > Java > Compiler 來修改設定。 全選Classfile Generation選項卡內的選項(這裡的選項是為了能把Debug需要的資訊也寫入到class位元組碼檔案[d1])。然後從eclipse匯出工程為remoting-debug.jar。

2、伺服器執行

Java程式碼  

1. java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000 -jar remoting-debug.jar  

3、本地除錯

     執行後,選擇 Run>DebugConfigurations...>Remote Java Application 然後:

    * 在Project選項卡選擇需要除錯的project。(其實只要選擇其中一個你要除錯的的project即可)

    * Connection TypeStandard (Socket Listen)

    * Port為address的值8000

Tomcat應用:

 1、在startup.bat的":end"前增加

Shell程式碼  

1. set JPDA_TRANSPORT=dt_socket  

2. set JPDA_ADDRESS=8000

  

3. set JPDA_SUSPEND=y  

4.   

5.   

6. call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%  

以上設定的這些引數最終在catalina.bat中被呼叫!

2、參考【java程式】的[步驟3]的操作。 在eclipse裡面的設定和上面的java相同。

參考:

d1 missing line number attributes的解決

寫道

Eclipse下Debug時彈出錯誤“Unable to install breakpoint due to missing line numberattributes,Modify compiler options togenerate line number attributes" 

遇到這個錯誤時找到的解答方案彙總: 
1、使用Ant編譯時,未開啟debug開關,在寫javac 任務時確認debug=true,否則不能除錯。THe settings for the eclipse compiler don't affect the ant buildand even if you launch the ant build from within eclipse. ant controls it's owncompiler settings.you can tell ant to generate debugging info like this 'javac... debug="true".../>(我的問題是因為這個原因); 
2、編譯器的設定問題,window->preferences->java->Compiler在compiler起始頁,classfile Generation區域中確認已經勾選了All line number attributes to generated class files。如果已經勾選,從新來一下再Apply一下。或者從專案層次進行設定,專案屬性->java compiler同樣在起始頁,確定已經勾選 
Eclipse報的這個錯,無非就這兩個原因造成的