Debugging remote Java programs

The following documentation explains how to debug Java programs on your remote server. This function applies to programs that reside on a remote server with POWER Linux or AIX operating systems installed. There are two methods you can use to debug a remote application. The first method is a simple one-step process that accepts all of the defaults for the remote application. The second method allows you to specify extra variables and parameters through a customized launch configuration.

About this task

Method 1: To accept the default values for your application:
  1. In the Remote Systems view, drill-down through your folders and files until you find the executable Java class file you want to debug.
  2. Right-click the file, and select Debug > Host Java Application.

Method 2: To specify extra variables and parameters:

Procedure

  1. In the Remote Systems view, drill-down through your folders and files until you find the executable Java class file you want to debug.
  2. Right-click the file, and select Debug > Host Java Application... to invoke the launch configuration dialog box for remote debugging.
  3. In the Name field, enter a name for the new configuration, such as Java Debugging.
  4. If you have a local project with associated Java files, check the Has associated Java project check box. Click Browse to navigate to the local folder that contains all of your Java files.
  5. In the Main class field, specify your main Java class, if this field is not automatically completed.
  6. In the Remote Working Directory field, specify the directory on the remote server where you want to run the debugging.
  7. Click the Arguments tab. Enter any necessary program arguments or Virtual Machine (VM) arguments and click Apply.
  8. Click the Classpath tab. Click Add to specify any new classpaths. Multiple selection is supported when you browse for files. Click Apply.
  9. Click the Environment tab. Click New to add environment variables if they are necessary.
  10. Click the Source tab. Here is where you specify the remote source location for debugging. By default, this location is the same as the remote working directory specified in the Main tab. Click Add to specify other remote source locations.
    1. The Add Source dialog box displays. Here is where you can specify the types of remote source to debug. Select Remote Folder for remote Java or class files, or Remote Archive for an archive file, such as a Jar file. Click OK.
    2. In the Browse for Folder dialog box, navigate through the connections displayed to find the remote source location for your Java code. Note that you can browse to multiple servers, to specify class files in various locations. This is useful if for some reason the class files are not available during run time and you need to specify a different server location.
    3. Click the folder that contains your Java source and click OK.
    4. Now, in the Source tab, beneath Source Lookup Path, you can see the addition for your remote server location. This is how you can specify remote source locations in future. By default, the first found source is used for debugging. If you want to search all duplicate source locations, check the Search for duplicate source files on the path check box. During the debug session, you will be prompted to select which source to use from a list of duplicate sources. Click Apply.
  11. Click the Advanced tab. You can specify the host port that you want to use for remote Java debugging. Typically, the debugger automatically detects a free port for you.
  12. Click the Common tab to define additional properties for the configuration:
    1. Use the radio buttons to select whether you want this configuration to be Local to your workbench instance, or Shared with your team.
    2. Select one of the toolbar buttons check boxes, where you want the configuration to display as a favorite (a bookmarked shortcut).
    3. Click Apply.
  13. Click Debug.

Results

The Debug perspective automatically opens and shows the different views you can use to debug your program. You can work within this perspective to diagnose errors. See Debug information for more instructions and links to task descriptions.

You can also launch the debug dialog box from the Run > Debug workbench menu, or the Debug toolbar buttons .

Note that your launch configuration is saved. The next time you invoke the launch configuration dialog for debugging and Remote Java application, the Remote Java debugging configuration is selected automatically. You can use this configuration, create a new configuration, or right-click and duplicate the existing configuration if you only want to modify one or two attributes.


Feedback