---
title: "How to debug code from rt.jar with JDK 1.4.1?"
author: "chimae"
date: "2005-04-15T10:17:00Z"
tags: []
slug: "how-to-debug-code-from-rt-jar-with-jdk-1-4-1"
draft: false
lastmod: "2005-04-15T10:17:00Z"
id: 110901
url: "https://chimae.iteye.com/blog/110901"
---

blocnjbb.oA: If you want to debug code from rt.jar you will get some information like "can't debug - absent line information."  
This small howto will tell you how.  
Create your own rt.jar (myrt.jar)  
— create a directory (newruntime) with a src directory  
— unzip the jdk source into the src directory  
— create a new java project with the project contents directory newruntime  
— let it compile - takes a while  
— export as a jar file Create a new JRE configuration  
— Prefrences &gt;&gt; Java &gt;&gt; Installed JREs &gt;&gt; Add  
— Browse to the usual JRE home directory  
— uncheck "use default system libraries"  
— add myrt.jar as an external jar above rt.jar Verify  
—While debuging check the command line ("Properties" page of the processin the debug perspective) to make sure that myrt.jar is on the bootclasspath  
— if not add myrt.jar to the bootclasspath on thecommmandline in your run configurations: -Xbootclasspath/p:C:dir omyewruntimemyrt.jar .

And another answer:

For the interested here a step-by-step explanation with script:

(1) The bottom line is:  
\* get the JDK source (i did it with version 1.4.1)  
\* get the original rt.jar for the same version  
\* unzip the rt.jar into a directory OriginalRT  
\* unzip the JDK source into a directory RTSource

(2) Now the fun starts:  
\* delete all files from RTSource that are NOT contained in OriginalRT  
(apparently old classes, they do not compile ...)  
\* compile the rest of the java files in RTSource with the "generate debug  
information" flag (and the RTSource directory, dt.jar, tools.jar and  
htmlconverter.jar in the classpath)  
\* copy all compiled classes that are in OriginalRT but not in RTSource into  
the corresponding place in RTSource  
\* jar RTSource into a file rt\_debug.jar  
\* use rt\_debug.jar instead of rt.jar in your classpath -&gt; et voila!

I found a cygwin script on the web doing all the things described in (2),  
here it is in case you want to use it (thanks to the original creator of the  
script!):

*#!/bin/sh*

*# Change these four paths = as required*

*# Base dir*  
*JAVA\_HOME=/cygdrive/c/j2sdk1.4.1*

*# Where src.zip was extracted*  
*JAVA\_SOURCE=/cygdrive/c/JavaSourceCompile/RTSource*

*# Where rt.jar was extracted*  
*RT\_CLASSES=/cygdrive/c/JavaSourceCompile/OriginalRT*

*# Where to put the compiled classes*  
*OUT\_DIR=/cygdrive/c/JavaSourceCompile/RTSource*

*# These are the required options for javac, do not change*  
*OPTIONS="-g -nowarn -sourcepath . -d \`cygpath -wp $OUT\_DIR\` -source*  
*1.4 -target 1.4"*  
*SEP=";"*

*CLASSPATH=$JAVA\_HOME/lib/dt.jar$SEP$JAVA\_HOME/lib/tools.jar$SEP$JAVA\_HOME/li*  
*b/htmlconverter.jar*  
*JAVAC\_HOME=$JAVA\_HOME/bin*

*# Loop through each java file in the source dir*  
*cd $JAVA\_SOURCE*

*#${JAVAC\_HOME}/javac -classpath \`cygpath -wp $CLASSPATH\` $OPTIONS*  
*\`cygpath -wp ./com/sun/corba/se/ActivationIDL/ActivatorHelper.java\`*

*#/usr/bin/find -name "\*.java" | while read JAVA;*  
*#do*  
*# echo $JAVA*

*# Is this file part of rt.jar, or is it an obsolete source file*  
*# eg = com/sun/corba/se/internal/Interceptors/ThreadCurrentStack.java*

*# CLASS=\`echo $JAVA | sed "s/.java/.class/g"\`*  
*# echo ${RT\_CLASSES}/${CLASS}*  
*# if \[ -e ${RT\_CLASSES}/${CLASS} ];*  
*# then*  
*# # Has this file already been compiled*  
*# if \[ -e ${OUT\_DIR}/${CLASS} ];*  
*# then*  
*# echo Already compiled.*  
*# else*  
*# ${JAVAC\_HOME}/javac -classpath \`cygpath -wp $CLASSPATH\` $OPTIONS*  
*\`cygpath -wp $JAVA\`*  
*# fi*  
*# else*  
*# echo Obsolete source file.*  
*# fi*  
*#done*

*# Now check for any files that are in rt.jar but not src.zip*  
*cd $RT\_CLASSES*  
*/usr/bin/find . -type f | while read CLASS;*

*do*  
*if \[ ! -f ${OUT\_DIR}/${CLASS} ]; then*  
*echo Not found : $CLASS*  
*# Uncomment this once the script has been run and all classes have*  
*successfully compiled*  
*# cp --parents $CLASS $OUT\_DIR*  
*fi*  
*done*

That runs for a while, because it's quite some amount of classes - but it  
works!