Use eclipse for remote debugging

Source: Internet
Author: User
Today I decided to do something meaningful and write a blog with images and texts. Why do I need images and texts? Because a lot of things can be said in a language do not understand, from a previous article I published can be seen, http://blog.csdn.net/sunyujia/archive/2008/03/23/2211109.aspx my friends ordinary reaction after reading think Yun, maybe it's too simple for me to write. Let's start with the question below. Remote debugging is to use eclipse to track and debug Web applications on machine B in one step on machine A. Of course, there is no problem in debugging Web applications on machine, 90% I am debugging Local Web applications. I don't want to talk about the meaning of remote debugging. Everyone will think of its advantages. You can debug applications in non-local testing environments locally, this is a wonderful thing, so I won't talk about its advantages. So how about local debugging? I like local debugging and use the method described below. Why don't I use myeclipse or WTP, tomcatplugin. Below I will elaborate on the defects of starting Web applications in Eclipse: I like to use myeclipse for Web deployment, but I do not like to use myeclipse to start Tomcat. Of course, WTP, tomcatplugin and so on do not like it. The advantage of using myeclipse for deployment is that it is very flexible. It can be deployed not only to Web applications, but also to any specified path. However, if you use myeclipse to start Tomcat, there are the following problems:. card, especially when multiple applications are started at the same time. b. if there are more than 100 breakpoints, for example, each unused breakpoint must be disabled or simply deleted, that is to say, when the web application is started, the debug mode or run mode is determined. Switch is not allowed in the middle. C. Once eclipse dies, the Web application will be disconnected. D. for programs, the relative paths and class loading paths are completely different from those when the system is officially running (depending on the specific plug-ins, the deployment methods of each plug-in are not the same ), that is, there is a difference between the relative path and the class loading environment for independent running of Web applications. Of course, skilled Veterans can easily solve this problem, but as far as the domestic situation is concerned, many beginners are still worried about this issue. E. By the way, this topic is irrelevant. The eclipse console cannot fully simulate the CMD console, and some stream operations may be faulty. For example, how can pushbackinputstream be used for local debugging through remote debugging? A. The running speed is better. B. during the running period, you can use eclipse to connect to the Web application for debugging. After debugging, You can disconnect the connection. You can re-connect it when debugging is required. The breakpoint disabling function may be rarely used, because it is free to switch between debug and run modes. C. Web applications run independently, so you don't have to worry about getting rid of Eclipse. D. The environment can be consistent from development to online running. After talking about it for half a day, people who have never used it may still not understand it. It doesn't matter. You can read the following and then look back at the above. The following is a small example of how to perform remote debugging. Environment: tomcat, Eclipse, remote debugging does not require any plug-ins. Of course, you can use myeclipse to deploy the web application to Tomcat. Note that it is only deployment. Generally, you do not need to configure the myeclipse Web server to use remote debugging, myeclipse serves only one copy file, but now myeclipse can specify the directory copy at will. That is, the custom location in the deployment dialog box. We recommend a small plug-in for copy files. With this plug-in, you do not need to deploy myeclipse. Filesync plugin for eclipse http://andrei.gmxhome.de/filesync/index.html the author of this plug-in also wrote a lot of other useful plug-ins, you can take a look. The source code of this example is very simple: the JSP source code is as follows: Index. JSP <% COM. syj. test. debugtest. test ("sunyujia test"); %> Hello remote debug creates a breakpoint in the test method of the debugtest class, which can be tested as follows: 1. deploy the web application to the webapp directory of Tomcat 2. modify tomcat/bin/startup. BAT file. Add the following code at the beginning: Set catalina_opts =-server-xdebug-xnoagent-djava. compiler = none-xrunjdwp: Transport = dt_socket, Server = Y, suspend = N, address = 8000 note that the preceding command must be written as one line without line breaks, -The front is a space-the back is a non-space, because the display resolution is different, this article may have a line feed when displayed. For more Web Server Remote debugging parameters, see. 6. open a browser to access the Web application deployed in step 1 and access index. jsp7. when the browser accesses index. in JSP. syj. test. debugtest. because the breakpoint is set in the test method, the program will be intercepted by the breakpoint. click Disconnect when debugging is not required. Click debug when debugging is required. This is very convenient. When the source code of a non-project is referenced during the debugging process (for example, tracing to tomcat or spring, in hibernate), the system will prompt that the source code cannot be found, and click the corresponding prompt button (there is only one button in the editor area at that time, so don't ask which button) to add the source code for further debugging, or add the required source code before configuring Debug. In the source tab, the specific Basic Debugging knowledge is not covered in this topic, I just want to introduce it more. Remote debugging is introduced here. It is still hard to print so many words. Please indicate the source for reprinting. Thank you!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.