Using Eclipse remote Debugging and principles

Source: Internet
Author: User

Today, the problem of locating Linux server-side Java applications, using Eclipse remote debugging Java applications, is probably the most common and fundamental way to locate the server side, and at least two colleagues with several years of development experience do not know this method, I feel very surprised, too.

This article focuses on the principle of remote debugging, in addition to the introduction of remote debugging Java applications using Eclipse.

JVM principle

As we all know, Java has a good cross-platform and security because of the introduction of the virtual machine JVM. Java files are compiled by Javac. Class files are also called bytecode files, bytecode files are executed by the JVM and translated by the translator into different machine codes (0101010010101) that each machine knows, so that the JVM supports the cross-platform of Java.

Application Scenarios for remote debugging

Remote debugging is useful, especially if your development environment is running Java applications on Windows, on a remote Linux server, or on a mobile platform, and Java provides a series of interfaces and protocols that allow local Java files to connect and communicate with the remote JVM.

Debugger schemas

According to Sun's JPDA specification, the program used for debugging is often referred to as debugger, and the program being debugged is called debuggee, and the debugger architecture is shown in Figure 1 below.


             Components                      Debugger Interfaces                 /    |--------------|                /     |     VM       | debuggee-----(      |--------------|  <----Jvmti-java VM Tool Interface                \     |   Back-end   |                 \    |--------------|                 /           | Comm Channel--(            |  <------------Jdwp-java Debug wire Protocol                 \           |                 /    |--------------|                /     |  Front-End   | Debugger-----(      |--------------|  <----Jdi-java Debug Interface                \     |      UI      |                 \    |--------------|
Figure 1. Java Debugger Architecture

This schema is read from the bottom up, and is roughly interpreted as: the program used for debugging uses the UI and, through protocol, invokes the remote JVM process.

In fact, the JVM, as long as the local Java source code to ensure that the same as the target application, the local Java source can be used to connect the socket to the remote JVM, and then perform debugging. So in this socket attach mode (described below), local only need to have source code, Java applications do not have to start.

Remote debugging in two ways Figure 2 describes two ways of remote debugging-the above means that eclipse is configured as a socket listen, the following is the socket attach mode


Figure 2. Two ways to debug remotely

Debugging Java remotely with eclipse
Eclipse Configuration: Menu (Eclipse): Run-->debug configurations Open the Debug Configuration panel, configure

Note that if the Java source code does not match the target application, the debug feature will not work correctly.

Select the Allow termination of remote VM option to terminate the connection during application debugging, such as:

This allows you to debug a remote Java application as if you were debugging a Java program locally after the connection is remotely debugged.

Conclusion

The above socket attach remote Debug method is more used in the actual project, the use of the process of thinking about the principle, so many times after the practice will have their own understanding of this function:)

Using Eclipse remote Debugging and principles

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.