使用Eclipse 远程调试java 应用程序
ECLIPSE操作技巧

ECLIPSE操作技巧Eclipse是一款广泛用于Java开发的集成开发环境(IDE),它提供了许多便捷的操作技巧,可以大大提高开发效率。
以下是一些常用的Eclipse操作技巧:1. 快速查找:可以使用快捷键Ctrl + Shift + L来查找当前代码中光标所在的方法或变量的出处。
还可以使用Ctrl + O来查找当前文件中的所有方法和变量。
此外,还可以使用Ctrl + F来进行文本查找和替换。
2. 快速打开文件:可以使用快捷键Ctrl + Shift + R来快速打开任意文件。
在打开文件的对话框中,可以使用通配符(*)来进行模糊匹配。
3. 快速跳转:可以使用快捷键Ctrl + Shift + T来快速跳转到指定的类。
此外,还可以使用Ctrl + 鼠标左键来跳转到类或方法的定义处。
4. 代码补全:可以使用快捷键Ctrl + Space来进行代码补全。
当输入一个类名或方法名时,按下Ctrl + Space会显示与之相关的建议。
5. 代码重构:可以使用快捷键Ctrl + Shift + R来进行代码重构。
例如,可以使用该快捷键将一个方法提取为一个新的方法或将一个变量提取为一个新的字段。
7. 快速修复错误:可以使用快捷键Ctrl + 1来快速修复代码中的错误。
当代码出现编译错误时,按下Ctrl + 1会显示与之相关的建议,并提供修复错误的选项。
8. 快速运行程序:可以使用快捷键Ctrl + F11来快速运行当前项目。
在运行配置中选择一个配置并按下Ctrl + F11即可运行该配置。
9.快速调试程序:可以使用快捷键F11来快速调试当前项目。
在调试配置中选择一个配置并按下F11即可开始调试。
12. 代码导航:可以使用快捷键Ctrl + E来快速导航代码。
按下Ctrl + E会显示当前文件中的所有类和方法,可以使用上下箭头键来进行选择。
13. 代码模板:可以使用快捷键Ctrl + Space来插入代码模板。
java调试程序的方法

java调试程序的方法Java调试程序是开发过程中非常重要的技能,它帮助您找出代码中的错误和问题,并对其进行修复。
本文将介绍Java调试程序的一些常用方法,包括使用IDE调试工具、使用日志调试、使用断点调试以及使用异常处理。
一、使用IDE调试工具IDE(集成开发环境)是一种强大的工具,在Java开发中常用的IDE有Eclipse、IntelliJ IDEA和NetBeans等。
IDE提供了许多高级调试工具,使得调试过程更加简单和高效。
1.断点调试:在代码中设置断点,当代码执行到断点处时,程序将停止执行,您可以逐行查看代码的执行过程,并观察变量的值。
通过断点调试,您可以快速找到代码中的问题。
2.监视变量:在IDE中,您可以选择监视变量,当程序执行到一些位置时,IDE会显示该变量的值。
通过观察变量的值,您可以找到与预期不符的情况。
3.查看堆栈信息:在程序运行过程中,如果发生异常,IDE会显示堆栈信息,其中包含了执行过程中的方法调用链。
通过查看堆栈信息,您可以追踪异常发生的位置,并找出造成异常的原因。
4.单步调试:在IDE中,您可以选择逐行执行代码,通过单步调试,您可以对代码的执行过程进行详细的观察,以检查代码是否按照预期执行。
二、使用日志调试日志是程序运行过程中生成的信息记录,通过在代码中添加日志语句,可以帮助您追踪代码执行过程,找到问题所在。
1.日志级别:日志通常有不同的级别,如DEBUG、INFO、WARN和ERROR等。
在调试时,可以将日志级别设置为DEBUG,这样可以显示更详细的信息,帮助您找到问题。
2. 日志输出:在Java中,常用的日志库有Log4j和Logback等。
通过配置日志输出方式,您可以将日志信息打印到控制台、日志文件或其他目标,方便对问题进行分析。
3. 日志分析工具:有许多日志分析工具可以帮助您分析和查找日志信息。
例如,使用ELK Stack(Elasticsearch, Logstash, Kibana)可以将日志信息集中存储,并提供、过滤和可视化功能。
如何远程调试发布的代码

Eclipse远程调试Tomcat1.应用场景通过Java的JPDA远程调试将本地源码与部署服务器连接起来实现调试,其中要注意的是:1)程序源码与服务器上发布的编译过的代码版本保持一致,保证调试定位准确。
2)调试的过程中,部署在应用服务器上的项目是出于DEBUGE模式的。
2. 配置步骤2.1. 配置Tomacat调试模式1) 方式一启动Tomcat远程调试功能的另一种方法:打开apache-tomcat\bin 目录下的catalina.bat 文件,通过设置CATALINA_OPTS参数即可;同时还可以设置Java_home,JVM参数等…set CATALINA_OPTS=-server -Xdebug -Xnoagent piler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000启动jdpa.bat ,JVM会使用socket方式,打开8000端口并挂起,等待客户端接入。
如图:Windows系统: apach/bin/startup.bat开始处中增加如下内容:1.SET CATALINA_OPTS=-server -Xdebug -Xnoagent piler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address =8788Linxu系统: apach/bin/startup.sh开始处中增加如下内容:declare -x CATALINA_OPTS="-server -Xdebug -Xnoagent piler=NONE -Xrunjdwp:transp ort=dt_socket,server=y,suspend=n,address=8788"2.linux打开端口命令的使用方法。
nc -lp 8788 &(打开8788端口)4.查看是否打开8788端口netstat -an | grep 87882) 方式二复制startup.bat 为jpda.bat并做如下配置:set JPDA_TRANSPORT=dt_socket --连接方式set JPDA_ADDRESS=8000 --监听端口set JPDA_SUSPEND=y --是否挂起call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%2.2. 配置Eclipse远程接入1)打开Eclipse,导入项目源码(与被调试的代码一致)2)打开Debug Configuration选中New—打开debug配置页面Project: 选择被调试的项目Connection Type: 使用SocketAttachHost:tomcat服务器所在IP地址Port:8000(前面配置的监听端口)设置完成后,记得点击Apply按钮。
eclipse java web项目反编译

文章标题:深入探讨eclipse中Java Web项目反编译的方法与重要性在当今数字化时代,软件开发已经成为不可或缺的一部分。
Java作为一种流行的编程语言,在企业级应用开发中被广泛应用。
而在Java开发过程中,反编译在项目维护和安全性检查中扮演着至关重要的角色。
本文将从深度和广度两个方面对eclipse中Java Web项目反编译的方法与重要性进行全面评估,并提供有价值的观点和理解。
一、eclipse中Java Web项目的反编译方法1. 导入反编译工具:在eclipse中,可以通过导入各种反编译工具来实现对Java Web项目的反编译。
常用的工具包括JD-GUI、Procyon 等,它们能够将.class文件转换为易于阅读的源代码,帮助开发者更好地理解和维护项目。
2. 设置反编译快捷键:在eclipse的设置中,可以为反编译工具设置快捷键,便于开发者在需要时快速进行反编译操作。
这样可以提高效率,减少开发过程中出现的问题。
3. 调试和修复:通过反编译工具,开发者可以方便地进行调试和修复工作,及时解决项目中的bug和错误。
这也是保障项目质量的关键步骤。
二、eclipse中Java Web项目反编译的重要性1. 代码安全性检查:反编译工具可以帮助开发者检查项目代码的安全性,避免出现潜在的漏洞和安全隐患。
通过查看反编译后的源代码,可以及时发现并修复可能存在的安全问题。
2. 项目维护与升级:在项目维护和升级过程中,使用反编译工具可以更好地理解现有的代码结构和逻辑,有助于进行代码重构和优化。
这对于提升项目的可维护性和可扩展性非常重要。
3. 知识学习和技术共享:通过反编译工具,开发者还可以学习他人的优秀代码和技术经验,提高自身的编程能力和水平。
也可以共享自己的代码给他人学习,促进技术交流和共同进步。
个人观点与理解对我个人而言,eclipse中Java Web项目反编译不仅是一项必需的技能,更是一种重要的态度和责任。
SpringBoot项目远程Debug模式(Eclipse)

SpringBoot项目远程Debug模式(Eclipse)Spring Boot 是一个用于简化 Spring 应用开发的框架,它可以帮助我们快速搭建和部署应用。
在开发过程中,我们经常需要进行 Debug 来定位问题。
本文将介绍如何使用 Eclipse 远程 Debug Spring Boot 项目。
```javapublic class MyApplicationpublic static void main(String[] args)System.setProperty("spring.devtools.restart.enabled", "false");System.setProperty("java.awt.headless", "true");}```接下来,我们需要配置 Eclipse 来进行远程 Debug。
首先,打开Eclipse,找到要调试的项目,右键单击,选择 `Debug As -> Debug Configurations`。
在弹出的窗口中,选择 `Remote Java Application`,然后点击`New` 创建一个新的 Debug 配置。
在 `Connection Type` 中选择 `Standard (Socket Attach)`。
在`Connection Properties` 中,设置 `Host` 为 `localhost`,设置`Port` 为 `8000`(默认的远程 Debug 端口)。
然后,点击 `Apply` 保存配置。
现在,我们可以启动 Spring Boot 项目。
在项目启动完成后,点击Eclipse 的 Debug 按钮,选择刚刚创建的 Debug 配置。
然后,点击`Debug` 按钮来启动远程 Debug。
如果一切顺利,Eclipse 将连接到运行中的 Spring Boot 项目,并在远程服务器上进行 Debug。
Eclipse的Debug调试技巧

Eclipse的Debug调试技巧作为开发⼈员,掌握开发环境下的调试技巧⼗分有必要。
我们在编写java程序的过程中,经常会遇到各种莫名其妙的问题,为了检测程序是哪⾥出现问题,经常需要增加⽇志,看变量的值,这样调试很⿇烦。
假设我每天花费1⼩时在调试我的应⽤程序上的话,那累积起来的话也是很⼤量的时间。
由于这个原因,⽤这些时间来重视并了解所有使我们调试更⽅便的功能。
那能为你省下⼀些时间,也将会使你的⽣活更安逸、轻松。
⾸先我们需要注意三个点:不要使⽤System.out.println作为调试⼯具\使⽤⼀个⽇志分析器来阅读⽇志\启⽤所有组件的详细的⽇志记录级别⼀个关于调试的疯狂声明作为开头。
但它必须是要说的!尝试切分⼀下你那复杂的逻辑成多个独⽴的单元,并编写单元测试来检测你代码的正确性。
我想像如下这样的流程应该是发⽣得⾮常频繁的—-⼀些Debug模式的界⾯,共分为5个区域(1)Debug(调试)区域,显⽰当前正在调试代码是什么,在第多少⾏(2)Variables(变量)区域,显⽰变量的值。
(3)代码编辑区(4)代码结构区,显⽰代码中的各个⽅法。
(5)Console(控制台)区域。
⼀、条件断点我们通常调试断点的时候⼀般就是点击⾏号的左边,这个时候就会有断点被打起来。
在debug视图中,BreakPoint View将所有断点都列出来,但是我们可以添加⼀个boolean类型的条件来决定断点是否被跳过。
如果条件为真,在断点处程序将停⽌,否则断点被跳过,程序继续执⾏。
如果你只对应⽤中的某部分感兴趣的话,这个功能⾮常有⽤。
例如,如果你要在第13次循环的时候检查程序,或者在⼀个抽象⽗类中调试某些功能,⽽你只关注其中⼀个具体的实现。
你可以在断点视图中设置条件,或者通过代码旁边的蓝⾊断点标记的右键菜单(”Breakpoint Properties”)设置。
你可以在条件代码⽚段为true的时候暂停程序,或者当代码⽚段的值改变的时候挂起程序。
java跨项目调用方法

java跨项目调用方法Java跨项目调用方法背景在开发多个独立的Java项目时,有时我们会遇到需要在一个项目中调用另一个项目中的方法的情况。
这种情况下,我们就需要跨项目进行方法调用。
本文将介绍几种常用的方法来实现Java跨项目调用。
1. 通过Java RMI实现跨项目调用Java RMI(Remote Method Invocation)提供了一种机制,使得一个Java应用可以调用运行在另一个Java虚拟机上的对象的方法。
通过使用Java RMI,我们可以在不同的项目中建立远程连接,实现方法的调用。
使用Java RMI实现跨项目调用的步骤如下:1.定义接口:在被调用项目中定义接口,并在接口中声明需要暴露给其他项目调用的方法。
2.实现接口:在被调用项目中实现接口,并在实现类中实现接口中声明的方法。
3.启动RMI Registry:运行被调用项目时,需要启动RMIRegistry,用于注册被调用对象。
4.注册对象:在被调用项目中,将实现类注册到RMI Registry中,以供其他项目调用。
5.获取远程对象:在调用项目中,通过RMI Registry获取远程对象的引用。
6.调用方法:通过远程对象的引用,调用被调用项目中的方法。
2. 使用WebService实现跨项目调用WebService是一种基于Web的服务技术,通过使用HTTP协议和XML格式进行通信。
我们可以通过在被调用项目中发布一个WebService,然后在调用项目中通过SOAP协议调用WebService的方式实现跨项目方法的调用。
使用WebService实现跨项目调用的步骤如下:1.定义接口:在被调用项目中定义接口,并在接口中声明需要暴露给其他项目调用的方法。
2.实现接口:在被调用项目中实现接口,并在实现类中实现接口中声明的方法。
3.发布WebService:在被调用项目中通过WebService框架(如Apache CXF、Apache Axis等)发布WebService。
在Eclipse中使用debug(Eclipse调试常用技巧)

Eclipse调试常用技巧1、条件断点断点大家都比较熟悉,在Eclipse Java编辑区的行头双击就会得到一个断点,代码会运行到此处时停止。
条件断点,顾名思义就是一个有一定条件的断点,只有满足了用户设置的条件,代码才会在运行到断点处时停止。
在断点处点击鼠标右键,选择最后一个"Breakpoint Properties"断点的属性界面及各个选项的意思如下图,2、变量断点断点不仅能打在语句上,变量也可以接受断点,上图就是一个变量的打的断点,在变量的值初始化,或是变量值改变时可以停止,当然变量断点上也是可以加条件的,和上面的介绍的条件断点的设置是一样的。
3、方法断点方法断点就是将断点打在方法的入口处,方法断点的特别之处在于它可以打在JDK的源码里,由于JDK在编译时去掉了调试信息,所以普通断点是不能打到里面的,但是方法断点却可以,可以通过这种方法查看方法的调用栈。
4、改变变量值代码停在了断点处,但是传过来的值不正确,如何修改一下变量值保证代码继续走正确的流程,或是说有一个异常分支老是进不去,能不能调试时改一下条件,看一下异常分支代码是否正确?在Debug视图的Variables小窗口中,我们可以看到mDestJarName变量的值为"F:\Study\eclipsepro\JarDir\jarHelp.jar"我们可以在变量上右键,选择"Change Value..."在弹出的对话框中修改变量的值,或是在下面的值查看窗口中修改,保用Ctr+S保存后,变量值就会变成修改后的新值了。
5、重新调试这种调试的回退不是万能的,只能在当前线程的栈帧中回退,也就说最多只能退回到当前线程的调用的开始处。
回退时,请在需要回退的线程方法上点右键,选择"Drop to Frame"6、远程调试用于调试不在本机上的程序,有两种方式,1、本机作为客户端2、本机作为服务端使用远程调试的前提是服务器端和客户端的代码是一致的。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
外文翻译,网上搜索所得Debug Java applications remotely with EclipseUse the power of the Eclipse IDE to spread around your Java application debuggingLevel: IntermediateCharles Lu (charleslu@), Software Engineer, IBM 09 Dec 2008You don't need to debug Java™ ap plications on just your local desktop. Learn how to spread around your debugging using different connection types that make up remote debugging. This article explains the features and examples that show how to set up remote application debugging.Remote debugging can be useful for application development, such as developing a program for a low-end machine that cannot host the development platform, or debugging programs on dedicated machines like Web servers, whose services cannot be shut down. Other examples include Java applications running with limited memory or CPU power, such as mobile devices, or developers wanting to separate the application and development environments, etc.PrerequisitesIf you don't have it already, download Eclipse V3.4 (Ganymede). In Ganymede, the socket listening connector has been added to the Remote Java Application launch-configuration type. Eclipse's new socket listening connector allows you to start the Java debugger, which listens for a connection on a specific socket. The program being debugged can then be started with command-line options to connect to the debugger. Prior to the Ganymede release, only a socket-attachingconnector was provided, and the program being debugged had to be a debug host that was connected by the debugger. It is impractical for mobile devices to be a host due to insufficient memory and CPU power.To use remote debugging, Java Virtual Machine (JVM) V5.0 or later must be used, such as IBM® J9 or SunMicrosystems' Java SE Development Kit (JDK). In this article, we focus on remote debugging, rather than detail each of Eclipse's debugging features. See Resources for more information about debugging with Eclipse and where to find the aforementioned software.JPDA introductionSun Microsystems' Java Platform Debugger Architecture (JPDA) technology is a multitiered architecture that allows you to debug Java applications in all situations easily. The JPDA consists of two interfaces (the JVM Tool Interface and JDI, respectively), a protocol (Java Debug Wire Protocol), and two software components that tie them together (back-end and front-end). It's designed for use by debuggers in any environment. JPDA is not only for desktop systems but works well with embedded systems, too.The JVM Tool Interface (JVMTI) defines that a VM must provide for debugging. (Editor's note: Starting with Java V5, JVMTI replaced JVMDI, which was used in Java V1.4.) The Java Debug Wire Protocol (JDWP) describes the format of debugging information and requeststransferred between the process being debugged and a debugger frontend, which implements the JDI, such as Eclipse, Borland JBuilder, and many others. The program being debugged is often called the debuggee in Sun's JPDA specification. The JDI is a high-level interface to define the information and requests used for remote debugging. The architecture is structured as follows.Listing 1. The Java Platform Debugger ArchitectureComponents 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 |\ |--------------|Therefore, any third-party tools and VM based on JPDA should work together without complaint. This client-server architecture allows you to debug a Java program from a local workstation running the platform, or even debug it from a remote computer on your network.Before talking about the debug-scenario stuff, we need to introduce two terms used in the JPDA specification: connector and transport. A connector is a JDI abstraction used to establish a connection between a debugger application and a target VM. A transport defines how applications access and transmit data between the front end and back end. The connectors "map" to the available transport types and the modes of connection. In Sun's reference implementation of JPDA, two transport mechanisms are provided on Microsoft® Windows®: socket transport and shared memory transport. Available connectors:∙Socket-attaching connector∙Shared-memory attaching connector∙Socket-listening connector∙Shared-memory listening connector∙Command-line launching connectorIn establishing a connection between a debugger application and target VM, one side acts as a server and listens for a connection. At some later time, the other side attaches to the listener and establishes a connection. The connections allow the debugger application or the target VM to act as a server. The communications among processes can be running on one machine or different machines.The problem with debugging a Java program remotely is not in the debugger front end but the remote Java back end. Unfortunately, there is not much information about this in the Eclipse help system. In fact, JDI and JVMTI areimplemented by Eclipse and the Java runtime environment, respectively. The only thing we are concerned with is the JDWP, which contains the information to communicate with the JVMTI and JDI. The JDWP contains many arguments that have been added to invoke the application for the remote Java application. Following are some of the arguments used in this article.-XdebugEnables debugging features.-Xrunjdwp:<sub-options>Loads the implementation of JDWP in the target VM. It uses a transport and the JDWP protocol tocommunicate with a separate debugger application. Specific suboptions are described below.Starting from Java V5, you can use the -agentlib:jdwp option, instead of -Xdebug and -Xrunjdwp. But if you have to connect to the VM prior to V5, -Xdebug and -Xrunjdwp will be the only choice. Following are brief descriptions of the -Xrunjdwp suboptions.transportGenerally, socket transport is used. But shared-memory transport can also be used on the Windows platform, if available.serverIf the value is y, the target application listens for a debugger application to attach. Otherwise, it attaches toa debugger application at the specified address.addressThis is the transport address for the connection. If the server is n, attempt to attach to a debugger application at this address. Otherwise, listen for a connection at this port.suspendIf the value is y, the target VM will be suspended until the debugger application connects.For detailed explanations for each debug setting, refer to the JPDA documentation (see Resources).Listing 2 shows an example of how to launch a VM in debug mode and listen for a socket connection at port 8765. Listing 2. Target VM acts as a debug serverListing 3 shows how to attach to a running debugger application using a socket on host 127.0.0.1 at port 8000. Listing 3. Target VM acts as a debug clientRemote debugging features in EclipseEclipse is a graphical Java debugger front end. The JDI is implemented in org.eclipse.jdt.debug bundle. In this article, we don't discuss the details of JDI implementation. See Resources for information about Eclipse JDT and Java JDI technology.The first thing we want to know is which Eclipse connector to use. To learn the remote connection types provided by Eclipse, you can add a launch configuration in Remote Java Application by going to the Eclipse menu and selecting Run > Debug Configurations..., then selecting the connector from the dropdown list. Two connectors are provided in Ganymede:∙Socket Attach∙Socket ListenFor the socket-listening connector, the Eclipse VM will be the host to be connected by the remote Java application. For the socket-attaching connector, the target VM will be the host. There is no difference for application debugging between the two connectors — the user may choose. A good rule of thumb is to use the faster, more powerful computer as the VM debug host because of the computational resources required.Before debugging your Java application, you may need to make sure the debug options are all enabled for your remote application. If that information is not available, you will get an error message, such as "Debug information is not available" or "Unable to install breakpoint due to missing line number." You can modify the settings from the Eclipse menu by changing what's set in Window > Preferences > Java > Compiler.Figure 1. Debug options in EclipseDebug an application remotelyWe are ready to start debugging an application remotely. Let's do it step by step:1. Create a Java project with a simple classWe create a simple class for debugging purpose. Listing 4 shows the sample code.Listing 4. Sample code for debugging2. Set a breakpointSet a breakpoint in the code. In this example, we set the breakpoint in the line System.out.println("This isa test.");.Figure 2. Set breakpoints in Eclipse3. Debug the application locallyBefore debugging your application, ensure that the debug options described in Figure 1 are enabled for the project. It's unnecessary to debug an application locally, but we can make sure all the debug information is available. Right-click 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 breakpointmanagement, etc.Figure 3. Debug the application locally4. Export the Java projectWe will use this application as the debug target. Right-click 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 manuallyOpen a console to launch the application manually to make sure the Java runtime environment is configured properly.Listing 5. Sample to invoke Java application6. Debug the application remotelyCopy the JAR file to the appropriate location on the remote computer, 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 serverThe 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 EclipseStart Eclipse using the remote launch configuration and specify the target VM address of the remote application. To do this, click Run > Debug Configurations, and double-click 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 127.0.0.1.Figure 4. Configuration of socket-attaching connectionSelect Allow termination of remote VM option to terminate the VM to which you are connecting during application debugging.Figure 5. Terminate button in EclipseTarget VM acts as debug clientThe 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 listen-mode 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 socket-listening connectionClick 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 127.0.0.1 at port 8000.Listing 7. VM invocation sample for socket-listening connection in EclipseIf 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.ConclusionThis article illustrated how to use the Eclipse built-in 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. ResourcesLearn∙"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 plug-ins that implement a Java IDE supporting the development of any Java application, including Eclipse plug-ins.∙Check out the "Recommended 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 origin and architecture, and how to extend Eclipse with plug-ins.∙Expand your Eclipse skills by checking out IBM developerWorks' Eclipse project resources.∙To listen to interesting interviews and discussions for software developers, check out check out developerWorks podcasts.∙Stay current with developerWorks' Technical events and webcasts.∙Watch and learn about IBM and open source technologies and product functions with the no-cost developerWorks On demand demos.∙Check out upcoming conferences, trade shows, webcasts, and other Events around the world that are of interest to IBM open source developers.∙Visit the developerWorks Open source zone for extensive how-to information, tools, and project updates to help you develop with open source technologies and use them with IBM's products.Get products and technologies∙The Java 2 Standard Edition V5 or greater is available from Sun Microsystems.∙Check out the latest Eclipse technology downloads at IBM alphaWorks.∙Download Eclipse Platform and other projects from the Eclipse Foundation.∙Download IBM product evaluation versions, and get your hands on application development tools and middleware products from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere®.∙Innovate your next open source development project with IBM trial software, available for download or on DVD.About the authorCharles Lu is a software developer at the IBM China Software Development Lab and currently works on IBM Lotus Expeditor development. He is interested in device programming, instant messaging, and voice technology.本文来自于:/developerworks/java/library/os-eclipse-javadebug/index.html?S_TACT=105 AGX02&S_CMP=EDU使用 Eclipse 远程调试 Java 应用程序利用 Eclipse IDE 的强大功能远程调试 Java 应用程序 级别: 中级Charles Lu, 软件工程师, IBM 2009年12月9日在本地计算机上调试 Java™ 应用程序并不是惟一的选择。