Java debugger  

Graphical Java Debugger - JDebugTool


Home
Screenshots
Features
Download
Starting Out
Purchase
FAQ
Testimonials
News
Contact
About
JDebugTool RSS feed

 How To Debug

 How to debug various Java applications using the JDebugTool® graphical Java™ debugger. The following instructions augment the JDebugTool Starting Out:

  1. How to debug a Google Android™ app?

  2. How to debug a Java ME app?

  3. How to launch JDebugTool as an external tool in Eclipse?

  4. How to debug a NetBeans project in JDebugTool?

  5. How to remotely debug a Java application?

  6. How to debug an Apache Tomcat™ Servlet?

  7. How to debug an Apache Tomcat 5.0 JSP?

  8. How to debug a JSP (Java Server Pages)?

  9. How to debug an Applet?


  1. How to debug a Google Android app?

    Android Debugger

    The JDebugTool Java debugger can debug Android apps. The following instructions reference the Developing In Other IDEs Android documentation for information on using the Android command line tools.

    1. Use the android create project Android command to create a new Android project. Then build your Android project in debug mode using the ant debug command.

      Or create an Android Project using the Eclipse ADT (Android Development Tools) plug-in. Do not use the Eclipse Run or Debug actions, or DDMS perspective. Instead you will use the instructions below to debug using JDebugTool.

    2. You would then Mount your application's src directory, as your Source Path in JDebugTool.
    3. Create an AVD (Android Virtual Device) using the android create avd Android command, if you have not already.

    4. Launch the Android emulator using the

      emulator -avd your_avd_name

      Android command.

    5. Install your Android application's .apk file into the emulator using the

      adb install /path/to/your/app.apk

      Android command, if you have not already.

    6. Launch the DDMS (Dalvik Debug Monitor Server) using the

      ddms

      Android command.

    7. If you want to suspend your application on startup, waiting for the debugger to attach, launch the Dev Tools Android application on the emulator. Click on Development Settings. Under Debug App, select your application, and also check Wait for Debugger. Your application will continue execution, after the debugger attaches, so you will need to set breakpoints ahead of time.

      You can also use the android.os.Debug.waitForDebugger() method call in your application's code, to suspend the calling thread, waiting for the debugger to attach. The waitForDebugger() call returns immediately after the debugger attaches, so you will need to set a breakpoint after the call.

    8. Launch your application on the Android emulator.

    9. Back in the DDMS, click to expand (if necessary) the tree node for your emulator, and then click to select your application in the subtree of processes. (If the names of the processes are not being displayed, your application is probably the last process in the subtree.)

    10. In JDebugTool, select Attach... from the Target menu in the menu bar. In the resulting Attach to Target dialog, enter localhost as the Host Name, and 8700 as the Port Number, and finally click on the OK Button.

    11. Note if debugging on a real device, instead of the emulator, enable USB debugging, by checking the USB debugging checkbox under Settings | Applications | Development, on the real device. Also make sure that you set <application android:debuggable="true" in your AndroidManifest.xml

      If you are developing on MS Windows®, you will need to install the USB driver for Windows.

      See Developing on a Device for more details on Android device debugging.



  2. How to debug a Java ME app?

    The JDebugTool Java debugger can debug Java ME apps. The following instructions utilize the Java ME Platform SDK 3.0

    1. In the Java ME Platform SDK GUI, create a new project or open an existing project, if needed.

    2. You would then Mount your application's src directory, as your Source Path in JDebugTool.
    3. In the Java ME Platform SDK GUI, in the Projects tab, right-click on the project you want to debug, and select the Set as Main Project menu item, if needed. Make sure that Generate Debugging Info is checked, and that Obfuscation Level is Off, in the Project Properties.

    4. In the Java ME Platform SDK GUI, click on the Run Main Project in Debug Mode toolbar button. In the resulting pop up dialog, take note of the debugging port number. The Java ME emulator is also automatically launched in debug mode.

    5. In the Java ME emulator, launch your Java ME application, which will then be suspended, waiting for the debugger to attach.

    6. In JDebugTool, select Attach... from the Target menu in the menu bar. In the resulting Attach to Target dialog, enter the Port Number you took note of in Step 4. above, and finally click on the OK Button.

    7. Your Java ME application, will now be suspended in JDebugTool, on a JVM start event.



  3. How to launch JDebugTool as an external tool in Eclipse?

    1. In the Eclipse toolbar, click on the External Tools drop-down menu button, and select the External Tools Configurations... menu item.

    2. In the resulting External Tools Configurations dialog, click on Program in the tree on the left-hand side. Then click on the New launch configuration button in the dialog's toolbar.

    3. In the resulting form page, type JDebugTool in the Name field.

    4. In the Main tab, in the Location field, click on the Browse File System... button. In the resulting File Selection dialog, select the location of the JDK Java executable you will use to launch JDebugTool. For example:

      c:/Program Files/Java/jdk1.6.0_23/bin/java.exe

    5. In the Main tab, in the Arguments field, type the arguments required to launch JDebugTool. For example:

      -cp "c:/Users/Mike/jdebugtool/jdebugtool.jar; c:/Program Files/Java/jdk1.6.0_23/lib/tools.jar" com.debugtools.jdebugtool.Main

      Note well that there is no space after the semicolon. On UNIX® use a colon instead of the semicolon as the classpath separator.

      An optional JDebugTool project name may be specified as the last argument, in order for the debugger to open a specific project.

      If you name your JDebugTool project the same name as your Eclipse project, then you can click on the Variables... button under the Arguments field. In the resulting Select Variable dialog, select project_name from the list and then click on the OK button to insert the argument ${project_name} as the last argument in the Arguments field. Then eclipse will substitute the currently selected Eclipse project name (in the Package Explorer) as the last argument, when launching JDebugTool.

    6. Finally click on the Apply button in the External Tools Configurations dialog to save your settings. Then click on the Run button to test launch JDebugTool.

    7. Now you will be able to quickly launch JDebugTool from Eclipse by clicking on the External Tools drop-down menu button in the Eclipse toolbar and selecting the JDebugTool menu item.

    8. Assuming the default Eclipse project layout, you would Mount the following Source Path in JDebugTool. For example:

      c:/Users/Mike/workspace/MyProject/src

    9. Assuming the default Eclipse project layout, you would add the following CLASSPATH entry in the Run In Debugger dialog in JDebugTool. For example:

      c:/Users/Mike/workspace/MyProject/bin

    10. In Eclipse, make sure that Generate Debugging Info is turned on (which it is by default), by right-clicking on your Eclipse project and selecting Properties from the resulting pop-up context menu. In the resulting Properties dialog, click on Java Compiler in the left-hand side list. In the resulting form, under Classfile Generation, make sure that the following check boxes are checked:
      • Add variable attributes to generated class files (used by the debugger)
      • Add line number attributes to generated class files (used by the debugger)
      • Add source file name to generated class file (used by the debugger)


  4. How to debug a NetBeans project in JDebugTool?

    1. Assuming the default NetBeans project layout, you would Mount the following Source Path in JDebugTool. For example:

      c:/Users/Mike/projects/MyProject/src

    2. Assuming the default NetBeans project layout, you would add the following CLASSPATH entry in the Run In Debugger dialog in JDebugTool. For example:

      c:/Users/Mike/projects/MyProject/build/classes

    3. In NetBeans, make sure that Generate Debugging Info is turned on (which it is by default), by right-clicking on your NetBeans project and selecting Properties from the resulting pop-up context menu. In the resulting Project Properties dialog, click on Compiling under Build, in the Categories tree. In the resulting form, make sure that the Generate Debugging Info checkbox is checked.



  5. How to remotely debug a Java application?

    You will need to invoke your Java application with special JVM debugging flags, for example (all on one line):

    jdk1.6.x/bin/java -agentlib:jdwp=transport=dt_socket,server=y,address=8000 test.Test args

    This will suspend your application on a JVM start event, waiting for a Java debugger to attach using a network socket connection, on port 8000.

    For JDebugTool to attach to your application, use the Target | Attach... menu item from the menubar, and the resulting Attach Dialog. Click on the Socket tab, and fill in the Host Name that your application is running on, and Port Number 8000 in this example. Finally click on the OK button.

    See JDebugTool's Context sensitive Help Viewer for other examples, on how to invoke your application. For the official documentation from Sun, see the JPDA Connection and Invocation Details for JDK 1.6, JDK 1.5, JDK 1.4 or JDK 1.3.

    It is also possible for JDebugTool to listen for a connection from your application, use the Target | Listen menu item from the menubar, and the resulting Listen Dialog.



  6. How to debug an Apache Tomcat Servlet?

    Tomcat Debugger

    JDebugTool can debug Tomcat Servlets. How to configure Tomcat to support remote debugging, depends on how you start Tomcat:

    • You can start Tomcat using catalina jpda start as follows:

      First make sure you have defined the environment variable JAVA_HOME to point to the root directory where you have the JDK installed. Then simply invoke on Windows

      $CATALINA_HOME/bin/catalina.bat jpda start

      or on Unix®

      $CATALINA_HOME/bin/catalina.sh jpda start

      The default transport of dt_shmem on Windows, and dt_socket on Unix can be changed by defining the JPDA_TRANSPORT environment variable. Also the default address of jdbconn on Windows, and 8000 on Unix can be changed by defining the JPDA_ADDRESS environment variable.

    • If you run Tomcat using a service wrapper, add for example, the following remote debugging JVM options before any other JVM options (check the documentation for the service):

      -agentlib:jdwp=transport=dt_socket,server=y,address=8000

    Then in JDebugTool, select Attach... from the Target menu in the menubar, to display the Attach to Target dialog. If using the shared memory transport, select the Shared Memory tab, and enter jdbconn in the Shared Memory Name field. If using the socket transport, select the Socket tab, and enter 8000 in the Port Number field. If you are debugging Tomcat remotely (on a different computer) also enter the Host Name field with the hostname or IP address of the computer where Tomcat is running.

    Finally click on the OK button in the Attach to Target dialog in JDebugTool. You should now be attached to Tomcat, and ready to debug.



  7. How to debug an Apache Tomcat 5.0 JSP?

    You can indirectly debug a Tomcat 5.0 JSP, by generating the corresponding Java source file, and then Mounting the corresponding Source Path in JDebugTool.

    First you will need to attach JDebugTool to Tomcat as described in How To #6 above. Then you will need to invoke your JSP to determine where the generated Java source file is created. For example, you would then Mount the following Source Path (see FAQ #1):

    $CATALINA_HOME/webapps/mywebapp/WEB-INF/classes

    where mywebapp would be the corresponding name of your web app. You are now ready to debug the generated Java source file as usual.



  8. How to debug a JSP (Java Server Pages)?

    You can indirectly debug a JSP by saving the generated Java source code of the JSP and mounting the generated Java source code in JDebugTool (see FAQ #1).

    See also How To #7 How do I debug an Apache Tomcat 5.0 JSP?



  9. How to debug an Applet?

    Basically you need to attach (see the Target | Attach... menu item from the menubar, and the resulting Attach Dialog) to the Java Plugin. See Applet Debugging Support from Sun, for JDK 1.6, JDK 1.5 or JDK 1.4, on how to configure the Java Plugin to support debugging (and being attached to by JDebugTool).

View the Screenshots or Download now.


©2001-2010. debugtools.com LLC. All rights reserved.     Terms of Use     Trademarks     Privacy Statement