Many of us work on a project which runs on Linux operating system and we do development mostly on Windows. Since I am working in Investment banking and finance domain I have seen use of Linux server for running electronic trading application quite a lot, which makes development difficult because you don't have code running on your development machine.
Some time we managed to run the project in windows itself which is essential for development and debugging purpose but many times its not possible due to various reason e.g. your project depends upon some of the platform dependent library or some Linux module whose windows version may not be available or your project is too big to run on windows and its heavily connected to upstream and downstream system its almost impossible to create same environment in your windows machine for development.
On such situation my approach to work is isolate the work I am doing and test that with the help of mock objects, Threads or by trying to run that module independently but this is also not a desired solution in some cases where
Eclipse provides us most useful feature called "Remote debugging" by using which you can debug your Linux running process from your windows machine. believe me this become absolutely necessary in some condition and knowing how to setup remote debugging and working of remote debugging in eclipse can greatly improve your productivity. In this Eclipse tutorial I will try to explain eclipse remote debugging or how to setup remote debugging in eclipse.
Now let's see how we can setup remote debugging in Eclipse:
1) First setup your java project in Eclipse.
2) Select your project, go to "Run" Menu option and select "Debug Configurations"
Remote debugging with eclipse 1 |
3) This will open Debug Configuration window select "Remote Java Application" icon on left side, Right click and say "New".
eclipse remote debugging 2 |
4) After clicking on New, Eclipse will create Remote Java Application configuration for your selected project. Now next step is to setup host and port for remote debugging.
Remote debugging in Eclipse 3 |
5) Now put the host name and port on which your process is listening for debugger in Linux machine. Check the "Allow termination of remote VM" check box if you would like to close java application running on Linux from eclipse.
6) Now you are all set to remote debug your project. but before starting to debug make sure your java process is started with java debug settings and listening on same host and port, otherwise eclipse will not able to connect successfully.
7) To debug just click the "Debug" button in last screen where we have setup host and port.
8) You can also debug by going to "Debug Configurations" selecting your project in "Remote Java Application” and clicking on "DEBUG".
Java remote debug setting and JVM debug options
In order to remote debug a java application, that application must be started with following JVM debug options:
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y suspend=y -jar stockTradingGUI.jar
This will start java applicaiton stockTradingGUI into debug mode using Java Debug Wire Protocol (jdwp) protocol and it will listen on port 8001
suspend=y will ensure that that application will not start running until eclipse connect it on speicified debug port.It also important to note
That application must be start before eclipse tries to connect it other wise Eclipse will throw error "Failed to connect to remote VM. Connection refused" or "Connection refused: connect"
No comments:
Post a Comment