Troubleshooting Debug JDK Source cannot view local variables (recompile Rt.jar package)

Source: Internet
Author: User

I. Description of the issue
First, we need to understand why JDK source cannot observe local variables when debugging, because in the JDK, Sun has removed debug information when compiling classes in Rt.jar so that the values of local variables cannot be seen in eclipse.
In this case, if you look at the local variables at debug time, you must compile the corresponding source code to have debugging information.
To achieve this goal, one is to find online people have compiled the version, the rest can only be compiled on their own.
Below we provide a method for our own compilation, we hope to help you, if there is any problem, please leave a message.

Two. Solution
1. Select or create your working directory, for example I choose: e:\
2, in your working directory, create folder Jdk_src, used to store the source code; Create a folder jdk_debug for output compilation results.
3, from your machine installed JDK place to find src.zip, you have to Jdk_home can be found, such as my in the C:\Program files\java\jdk1.7.0_09 directory. Then extract the src into the jdk_src directory.
4, after the decompression, select the content you need to compile, delete the remaining. Generally choose a few folders as follows: Java javax org These three directories are ready to go.
5. Copy the Rt.jar from your jdk_homme\jre\lib to your working directory (that is, e:\), which allows you to reduce the file name entered on the command line.
6. Execute the following command:

dir /b/s/x Jdk_src\*.java > Filelist.txt

Create a file called Filelist.txt, which holds all the names of the classes you are going to compile.
7. Execute the following command:

Javac-j-xms16m-j-xmx1024m-sourcepath E:\JDK_SRC-cp2>&1

This command will compile all the files you specify, and output the compiled results to the Jdk_debug directory, generating the Log.txt journal file. This journal file records compilation warnings, but there are no errors.
8. Enter the Jdk_debug directory and enter the following command:

Jar CF0 Rt_debug.jar *  

This command can generate the jar package that we need to rt.jar with the compiled information.
9. Copy the generated Rt_debug.jar packet to the jdk_home\jre\lib\endorsed. If you don't have a endorsed directory, create it yourself.
10. If you are debugging in Eclipse. Click Window->installed JREs, select the appropriate JDK, click Edit,r and then select click Add External jars, select the Rt_debug.jar in our step 9, and you can.

Note: If the Rt.jar package already exists under the original JRE directory, the location of the newly compiled Rt_debug.jar will be placed before the original jar package, as shown in.

Now that you have completed all the steps, try debugging, if you can see the local variables, then congratulations on your success.


Three. References
1, the original link: http://blog.csdn.net/appleprince88/article/details/21873807
2. Debug JDK source can ' t watch variable what it is
Http://stackoverflow.com/questions/18255474/debug-jdk-source-cant-watch-variable-what-it-is

Troubleshooting Debug JDK Source cannot view local variables (recompile Rt.jar package)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.