6 Replies Latest reply: Jul 18, 2008 6:29 AM by 843810 RSS

    How to work TRACE

    843810
      Hi,
      I'd like only do a Trace of my code but unfortunately I can't.
      I can't compile my code because there are a lot of errors, but doesn't matter , because I don't care these errors. I hope that I can use Trace also without compile the code.
      By the way, these are my command :
      C:\>\j2sdk1.4.2_01\bin\java -classpath C:\j2sdk1.4.2_01\lib\tools.jar Trace Proxy.java

      and I get :

      Exception in thread "main" java.lang.NoClassDefFoundError: Trace

      Please , help me , I'm driving crazy.

      Thanks in advance.
        • 1. Re: How to work TRACE
          800575
          Hi kento. Your command has two problems:
          - It tries to run the class named Trace but Trace is not on the classpath so it cannot be located.
          - It tries to trace 'Proxy.java', but the Trace program traces .class files not .java files.


          Trace.java is a JPDA demo program that is included in the JDK. See this for more info:
          http://java.sun.com/j2se/1.4.2/docs/guide/jpda/trace.html

          The Trace source code is included in
          <jdk142>/demo/jpda/examples.jar

          where '<jdk142>' is your JDK 1.4.2 installation directory.
          You have to build the Trace program before you can use it.

          To build Trace, do the following:
          mkdir examples
          cd examples
          <jdk142>/bin/jar xf <jdk142>/demo/jpda/examples.jar
          <jdk142>/bin/javac -classpath <jdk142>/lib/tools.jar com/sun/tools/example/trace/*.java

          To run trace on your program,
          cd <your directory>
          <jdk142>/bin/javac YourProgram.java
          <jdk142>/bin/java -classpath .:<jdk142>/lib/tools.jar:<your examples/ dir from above> com/sun/tools/example/trace/Trace YourProgram

          HTH
          • 2. Re: How to work TRACE
            843810
            hello,

            i am also not able to start a trace of my code.

            I use the following command :

            java �classpath tools.jar com/sun/tools/example/trace/Trace Foo

            but i receive the following error message :

            -----------------------------------------------
            Exception in thread main java.lang.NoCLassDefFoundError: com/sun/tools/example/trace/Trace

            ------------------------------------------------

            Foo ist the programm, i wanted to trace.

            all steps which are described by "JimHolmlund" are working fine but the last statement does not work.

            does somebody has a solution for that problem
            • 3. Re: How to work TRACE
              800575
              Looks like you don't have <your examples/dir> on your classpath. That is why it can't find the Trace class.
              • 4. Re: How to work TRACE
                843810
                hello jim ,

                thanks for your quick answer.

                why do i have to set the path of the file "Trace.class" to my classpath ?

                in my statement ,i had explicitly given the information , in which folder you can find Trace.class ( com/sun/tools/example/trace/Trace Foo )

                furthermore, I had temporary set the class path to C:\Programme\Java\jdk1.5.0\bin\com\sun\tools\example\trace,

                but it also doesnt work

                I hope you can say me what iam doing wrong
                • 5. Re: How to work TRACE
                  800575
                  The name of the class is com.sun.tools.examples.trace.Trace. This name, with . changed to /, so that it becomes a partial file pathname, must be located on the classpath. IE, the directory that contains com\ must be on the classpath. For more info, see:
                  [http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html]
                  • 6. Re: How to work TRACE
                    843810
                    hello jim ,

                    i have detected my error.

                    thanks jim , for your help