java source debug

原地址:http://stackoverflow.com/questions/18255474/debug-jdk-source-cant-watch-variable-what-it-is


Update: Actually I have just tried this process and it is not hard at all. Tested on Windows, JDK 1.7.0_11. All the commands are invoked from command line:

  1. Create your working folder. I chose d:\ root folder
  2. Inside your working folder create the source folder i.e. jdk7_src and output folder jdk_debug
  3. From your JDK_HOME folder get the src.zip file and unzip it inside jdk7_src
  4. Select what you will compile and delete the rest. For all of them you might need additional steps. I have chosen the folders:
    • java
    • javax
    • org
  5. From your JDK_HOME\jre\lib get the file rt.jar and put in the work folder (this is only for convenience to not specify too large file names in the command line).
  6. Execute the command: dir /B /S /X jdk7_src\*.java > filelist.txt to create a file named filelist.txt with the list of all java files that will be compiled. This will be given as input to javac
  7. Execute javac using the command:
    javac -J-Xms16m -J-Xmx1024m -sourcepath d:\jdk7_src -cp d:\rt.jar -d d:\jdk_debug -g @filelist.txt >> log.txt 2>&1 This will compile all the files in the jdk_debug folder and will generate a log.txt file in your working folder. Check the log contents. You should get a bunch of warnings but no error.
  8. Go inside the jdk_debug folder and run the command: jar cf0 rt_debug.jar *. This will generate your new runtime library with degug information.
  9. Copy that new jar to the folder JDK_HOME\jre\lib\endorsed. If the endorsed folder does not exist, create it.

Debug your program in Eclipse. Note how the variables are named normally (no more arg0, arg1 etc). Happy debugging :)

Java Debug是一种在代码执行过程中进行调试和排错的技术。通过在代码中设置断点,我们可以暂停程序的执行,并逐步检查变量的值和程序的流程,以便找到错误并进行修复。Java的IDE(集成开发环境)通常提供了调试工具,如在IDEA中,我们可以通过更改设置来显示集合中的空元素,以便更好地进行调试。 在Java Debug过程中,我们可以使用调试工具来监视变量的值、执行流程和方法的调用。我们可以使用断点来暂停程序的执行,然后逐步执行代码来检查变量的值和程序的行为。在IDEA中,我们可以通过单击行号旁边的空白区域来设置断点,或者使用快捷键Ctrl + F8来切换断点。 调试过程中,我们还可以使用调试工具的其他功能,比如查看变量的值、修改变量的值、观察表达式的值等。我们可以通过在IDEA的Debug视图中查看变量的值,或者使用System.out.println语句打印变量的值。例如,使用System.out.println("数组中第" + (i + 1) + "个元素为 :" + array[i]);可以在控制台输出数组中每个元素的值。 调试过程中,我们可以逐步执行程序,观察变量的值和程序的执行流程,以便找到错误并进行修复。当遇到问题时,我们可以使用调试工具来检查变量的值,查看方法的调用栈,以及查看程序的行为。通过调试,我们可以更好地理解代码的执行过程,快速定位并解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [java 程序猿必备技能——Debug详解](https://blog.csdn.net/TYRA9/article/details/128884528)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值