A debug trouble, need you help!~~
Hi,
I want to debug TTY. And I try to using commonds as following:
C:\jdb -classpath F:\com\sun\tools\example\debug\tty TTY
C:\jdb -classpath F:\com\sun\tools\example\debug\ttycom.sun.tools.example.debug.TTYBut I got the erro:"Exception in thread "main" java.lang.NoClassDefFoundError: F:\com\sun\tools\example\debug\tty"
I must make some mistakes. And how do I should imput my commond?
Thank you!
Duanyh
SJTU
[461 byte] By [
duanyha] at [2007-9-29 17:00:39]

> Hi,
> I want to debug TTY.
OK... you want to debug the com.sun.tools.example.debug.tty.TTY class.
Please excuse me if this is going over work you have already
done... I decided to start from the beginning for the benefit
of anyone else reading this thread.
NOTE: If you are following these example command lines, remember that
the separator char for directories on CLASSPATH is : on Unix
systems and ; on win32 systems:
1) Unpack the JPDA examples:
cd $JAVA_HOME/demo/jpda
jar -xvf examples.jar
2) Compile the example code for debugging:
javac -g -classpath "$JAVA_HOME/lib/tools.jar:." com/sun/tools/example/debug/tty/TTY.java
3) Create a HelloWorld.java class to be a victim for this debug session:
cat > HelloWorld.java
public class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
Compile the HelloWorld class:
javac -g HelloWorld.java
4) Start up com.sun.tools.example.debug.tty.TTY and have it debug
the HelloWorld class, using commands like this:
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8211,server=y,suspend=n -classpath "$JAVA_HOME/lib/tools.jar:." com.sun.tools.example.debug.tty.TTY HelloWorld
Initializing jdb ...
> stop in HelloWorld.main
Deferring breakpoint HelloWorld.main.
It will be set after the class is loaded.
> run
run HelloWorld
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: Set deferred breakpoint HelloWorld.main
Breakpoint hit: "thread=main", HelloWorld.main(), line=3 bci=0
3System.out.println("Hello, world!");
main[1]
5) At this point, the TTY class is busy debugging the HelloWorld
class. Since the TTY class was started with the appropriate
-Xdebug -Xrunjdwp:... flags, you can now attach to that process
on the pre-arranged port (8211 in this example) and examine it.
I suggest you do this from a separate command window:
jdb -connect com.sun.jdi.SocketAttach:port=8211
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
> threads
Group system:
(java.lang.ref.Reference$ReferenceHandler)0x295Reference Handler cond. waiting
(java.lang.ref.Finalizer$FinalizerThread)0x296Finalizercond. waiting
(java.lang.Thread)0x297Signal Dispatcher running
Group main:
(java.lang.Thread)0x1 mainrunning
(java.lang.UNIXProcess$3)0x299process reaper running
(com.sun.tools.example.debug.tty.VMConnection$1)0x29a output reader running
(com.sun.tools.example.debug.tty.VMConnection$1)0x29b output reader running
(java.lang.Thread)0x29cevent-handler cond. waiting
Group JDI [27940859]:
(java.lang.Thread)0x29fJDI Target VM Interfacerunning
(java.lang.Thread)0x2a0JDI Internal Event Handler cond. waiting
> suspend
All threads suspended.
> thread 0x1
main[1] where
[1] java.io.FileInputStream.readBytes (native method)
[2] java.io.FileInputStream.read (FileInputStream.java:194)
[3] java.io.BufferedInputStream.read1 (BufferedInputStream.java:220)
[4] java.io.BufferedInputStream.read (BufferedInputStream.java:277)
[5] sun.nio.cs.StreamDecoder$CharsetSD.readBytes (StreamDecoder.java:408)
[6] sun.nio.cs.StreamDecoder$CharsetSD.implRead (StreamDecoder.java:450)
[7] sun.nio.cs.StreamDecoder.read (StreamDecoder.java:182)
[8] java.io.InputStreamReader.read (InputStreamReader.java:167)
[9] java.io.BufferedReader.fill (BufferedReader.java:136)
[10] java.io.BufferedReader.readLine (BufferedReader.java:299)
[11] java.io.BufferedReader.readLine (BufferedReader.java:362)
[12] com.sun.tools.example.debug.tty.TTY.<init> (TTY.java:525)
[13] com.sun.tools.example.debug.tty.TTY.main (TTY.java:850)
At this point, your are debugging the JVM running com.sun.tools.example.debug.tty.TTY.main. You can
set breakpoints, resume the debug session, and so forth.