计算机专业毕业外文翻译--使用eclipse远程调试java应用程序(编辑修改稿)内容摘要:

abled for the project. It39。 s unnecessary to debug an application locally, but we can make sure all the debug information is available. Rightclick on the Java project, select Debug As and select Java Application (see Figure 3). If the application execution is stopped at the breakpoint, the debugging information is presented correctly. You can continue to use the debugging features, such as displaying the debug stack, variables, or breakpoint management, etc. Figure 3. Debug the application locally 4. Export the Java project We will use this application as the debug target. Rightclick on the Java project, select Export, select Java, then choose JAR file or Runnable JAR file to export the project. The JAR file will be generated at the desired location. Be aware that if the Java source does not match the target application, the debug function will not work correctly. 5. Run the Java application manually Open a console to launch the application manually to make sure the Java runtime environment is configured properly. Listing 5. Sample to invoke Java application java –jar 6. Debug the application remotely Copy the JAR file to the appropriate location on the remote puter, or even the same machine, invoke the debug server, and then attach a client to it. The simple Java application can act as a debug server or client. Depending on the configuration, you can choose either Socket Attach or Socket Listen connection type in Eclipse. Learn how to run the application as a server or client in the following two sections. Target VM acts as debug server The following example invokes the Java application on the remote side, acts as a debug server, and listens for a socket connection on port 8000. The target VM will be suspended until the debugger connects. Listing 6. VM invocation sample for socket attaching mode in Eclipse java Xdebug Xrunjdwp:transport=dt_socket,server=y,address=8000 jar Start Eclipse using the remote launch configuration and specify the target VM address of the remote application. To do this, click Run Debug Configurations, and doubleclick the Remote Java Application in the Eclipse menu. From the newly created launch configuration, specify the IP and port for target application. To run the remote application in the same machine, simply specify the host IP as localhost or . Figure 4. Configuration of socketattaching connection Select Allow termination of remote VM option to terminate the VM to which you are connecting during application debugging. Figure 5. Terminate button in Eclipse Target VM acts as debug client The second example is to use a simple Java application that acts as a debug client, and the debugger front end acts as a debug server. Eclipse uses the socket listenmode connection type for listening. The debug front end must be started in advance to listen on a specific port. Figure 6 shows a sample configuration to set up listening. Figure 6. Configuration of socketlistening connection Click the Eclipse Debug button, and the status bar will show the message waiting for vm to connect at port 8000... When you see that, start the remote application. Listing 7 shows how to invoke the Java application as a debug client and attach it to a running debugger application using a socket on host at port 8000. Listing 7. VM invocation sample for socketlistening connection in Eclipse java Xdebug Xrunjdwp:transport=dt_socket,address=:8000,suspend=y jar If everything goes well, the debug perspective will be displayed to support the application debugging, and the execution of the remote Java application will be stopped normally. This is similar to Step 3 that we did in local debugging (see Figure 3). At this point, you can use standard debugging functions, such as setting breakpoints and values, step execution, etc. Conclusion This article illustrated how to use the Eclipse builtin remote Java application configuration type to perform application debugging remotely. It introduced how to set up a Java application to invoke remote debugging and helped you understand the connectors Eclipse provides. Finally, you learned how to apply this technology to your projects. Resources Learn  Eclipse Ganymede at a glance is an overview of several Ganymede projects, along with resources for more information.  For an introduction to the debugging with the Eclipse platform, see Debugging with the Eclipse Platform.  Expand your Eclipse debugging knowledge by checking out Eclipse Debugging Resources.  Learn more about Java Platform Debugger Architecture by Sun Microsystems.  Read the Java Platform Debugger Architecture documentation to learn more about JPDA.  Read the Java Debug Interface documentation to learn more about JDI.  The JDT project provides the tool plugins that implement a Java IDE supporting the development of any Java application, including Eclipse plugins.  Check out the Remended Eclipse reading list.  Browse all the Eclipse content on developerWorks.  New to Eclipse? Read the developerWorks article Get started with Eclipse Platform to learn its o。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。