怎样在JCreator中能像JBuilder中那样单步调试?

解决方案 »

  1.   

    你新建立一个工程,编译程序,然后在主程序中按CTRL+F5进行调试,在调试过程中按F10可以进行单步调试。你看一下Build菜单你就会明白的。
      

  2.   

    This requires some modifications to the standard debugger setup. The goal is to attach the debugger to a running JVM process. In this example a simple console application will be waiting for input from the user.Step 1) Create a new project with the following classCODE
    import java.util.Scanner;public class KeyboardInput {   public static void main(String args[]) {
           
           System.out.print("input line : ");
           
           Scanner myScanner = new Scanner(System.in);
           
           String inputline = myScanner.nextLine();       System.out.println(inputline);
       }
    }
    Step 2) Modify the settings for running the applicationOpen the project properties window and select the JDK Tools tab. From the pulldown box select 'Run Application'.Select the default item from the list and press copy. A configuration window will popup. Name the new tool "Run with debugger".Command tab, uncheck all the boxesParameters tab. set the parameters string as follows 
    -classpath "$[ClassPath]" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,address=jdbconn,server=y,suspend=y $[JavaClass]Close the configuration window and enable the checkbox of "Run with debugger".Step 3) Modify the settings for running the debuggerOpen the project properties window and select the JDK Tools tab. From the pulldown box select 'debugger'.Select the default item from the list and press copy. A configuration window will popup. Name the new tool "Debugger jdbconn".Parameters tab, set the parameters string as follows -attach jdbconnClose the configuration window and enable the checkbox of "Debugger jdbconn".Step 4) Modify the default settings for the compilerOpen the project properties window and select the JDK Tools tab. From the pulldown box select 'compiler'.Select the default item from the list and press edit. A configuration window will popup. Parameters tab, enable the checkbox Include debug infoClose the configuration window and enable the checkbox of "Debugger jdbconn".Step 5) Lets see if it worksCompile the project with jdk 1.5.Set a breakpoint for the first statement of the main method. (~line 17)Hit the project execute button. A dos prompt will appear running your application in suspend mode with the following text 'Listening for transport dt_shmem at address: jdbconn'Press the project debug button and step through the program (F10) until CODEString inputline = myScanner.nextLine();Go back to the dos prompt window and type "hello" followed by enter.In JCreator, select/highlight the variable 'inputline' in the editor and press F8.The debugger output view will display ' inputline = "hello" '