Java Reference
In-Depth Information
remote application is sending debugging information. The number entered here
is arbitrary, but there must be nothing else running on the port, including other
Java applications with debugging enabled.
Don't confuse the debugging port number with your application server's
port number. The debugging port number in the
Run/Debug
Configu-
rations
window is the port number the debugger uses to communicate
with the application. This number should be the same as the one speci-
fied through the
-Xrunjdwp
switch when you launch the server. This has
nothing to do with the port number on which your application server is
handling
HTTP
requests (such as 80 or 8080).
WARNING
Debugging via shared memory
Windows users have the option of using shared memory, rather than a socket, for
communication between the application and the debugger. If you select this
option on the
Remote
tab of the
Run/Debug
Configurations
dialog, you'll be
asked to enter the name of the shared memory segment as specified when you
launched your application. In theory, there is a speed advantage to communicat-
ing in this manner, but your mileage may vary. Note that the shared memory
transport option only works when you're debugging an application running on
the same machine as
IDEA
.
Connecting to a remote application for debugging
Just as you would when debugging a local application, select the Run/Debug con-
figuration you've created for your remote debugging session on the
Remote
tab
of the
Run/Debug
Configurations
dialog and click the
Debug
icon on the main
toolbar or press
Shift+F9
. The debugger will attempt to attach itself to the appli-
cation using the settings specified in the configuration. If it's unable to do so for
any reason, such as if the program isn't running, you'll be dutifully informed.
Setting up IDEA as a debugging server
Rather than have
IDEA
connect to your process, you can flip things around and
have the application contact
IDEA
when something goes wrong. To do this, select
Listen
, rather than
Attach
, as the debugger mode on the
Remote
tab of the
Run/
Debug
Configurations
dialog, and pass the required
VM
parameters when
launching your application. When the condition you've set up (such as an
uncaught exception) occurs on the remote application, it will attempt to contact
IDEA
and establish a debugging session.