Eclipse

Java Debugger – Eclipse Remote Debugging Tutorial

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#===========================================================
# Configure JVM arguments.
# If JVM args are include in an ini file then --exec is needed
# to start a new JVM from start.jar with the extra args.
# If you wish to avoid an extra JVM running, place JVM args
# on the normal command line and do not use --exec
#-----------------------------------------------------------
--exec
-Xdebug
-agentlib:jdwp=transport=dt_socket,address=9999,server=y,suspend=n
# -Xmx2000m
# -Xmn512m
# -XX:+UseConcMarkSweepGC
# -XX:ParallelCMSThreads=2
# -XX:+CMSClassUnloadingEnabled
# -XX:+UseCMSCompactAtFullCollection
# -XX:CMSInitiatingOccupancyFraction=80
# -verbose:gc
# -XX:+PrintGCDateStamps
# -XX:+PrintGCTimeStamps
# -XX:+PrintGCDetails
# -XX:+PrintTenuringDistribution
# -XX:+PrintCommandLineFlags
# -XX:+DisableExplicitGC

Uncomment any other jvm environmental options you so desire for your debugging session. Regardless of the option chosen, you should see the following lines at the top of your jetty-distribution startup.
Listening for transport dt_socket at address: 9999

4. Conclusion

In this article, we saw Java Debugger and how to connect Eclipse to a remote server for debugging. We also saw how to configure the Eclipse debugging session. We have also examined how to start a server in debug mode. For this, we took an example of Jetty. 

When setting up the remote launch configuration there are a few items to take note of. You must ensure you enter the correct hostname i.e. the name of the remote computer where you are currently running your code. The hostname can also be the IP address of the remote machine, for example using 127.0.0.1 instead of localhost. The port number must be the number of the port on the remote machine.

Certain Java VMs support another way of starting a remote debug session. In this alternative connection type, the debugger is launched first. The debugger then waits and listens for the VM to connect to it. To debug this way, you must properly configure and launch a remote debug session, then launch the VM, specifying the location of your waiting debugger.

Mohammad Meraj Zia

Senior Java Developer
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button