Debugging Java code

You can debug Java code running under control of a Notes® client JVM (Java Virtual Machine).

Before you begin

The Notes® client supports Java debugging in the following three contexts. Each context has its own JVM. Only one user can debug at a time in each context.
  • Foreground - Java code that runs in the Notes® client interactively, for example, an agent triggered from the Actions menu.
  • Background - Java code that runs in the Notes® client under control of the task loader, for example, a locally scheduled agent.
  • Web preview - Java code being previewed in a browser through Domino® Designer, for example, an applet on a form.

Java code from a script library runs in the context of the calling code.

About this task

Do the following:

Procedure

  1. Add JavaEnableDebug=1 to the notes.ini file in the Notes® directory.
  2. Choose Tools > Java Debugging Preferences. This opens the "Java Debugging Preferences" dialog.
    1. To enable foreground debugging, select Client Agents/Applets and specify a port number to connect the Notes® and debugger computers.
    2. To enable background debugging, check Locally Scheduled Agents and specify a port number to connect the Notes® and debugger computers.
    3. To enable Web preview debugging, check Http Preview and specify a port number to connect the Notes® and debugger computers.
  3. Restart Notes®.
  4. Set up the element for debugging.
    1. Open the element in Domino® Designer.
    2. On the Properties tab, select Security then select Compile Java code with debugging information.
    3. Open the main class, for example, JavaAgent.java.
    4. Add sleep commands at the beginning. The duration must be long enough so you can connect with the debugger at runtime.
    5. Set a breakpoint at the line following the sleep commands.
    6. Save the element.
  5. Create a debug configuration.
    1. Open the main class.
    2. Click Run > Debug Configurations.
    3. In the "Debug Configurations" dialog, select Remote Java Application and create a new configuration.
    4. Name the configuration.
    5. Specify the project containing the element being debugged.
    6. Set the host to localhost or 127.0.0.0.
    7. Set the port to match the value set in the Notes® client.
    8. Click Apply and Close.
  6. Debug the element.
    1. Start the element in the Notes® client. For example, an agent might be started from the Actions menu.
    2. In Domino® Designer, open the main class. Ensure that a breakpoint is set.
    3. Click Run > Debug Configurations.
    4. Select the debug configuration that matches the element you are debugging and click Debug.
    The element stops at the breakpoint and you can debug. After starting the element, you must apply the remaining steps while the element is sleeping.
  7. To debug a second element, select the element through the Browse button in "Debug Configurations" and click Apply.