简体   繁体   English

将Eclipse作为调试器启动

[英]Launching Eclipse as a debugger

What's the equivalent of 相当于什么

System.Diagnostics.Debugger.Break(); System.Diagnostics.Debugger.Break();

in the Java world? 在Java世界中?

Purpose: I have a tomcat based webapp launched by a custom build tool and need to debug the application in eclipse. 目的:我有一个由定制构建工具启动的基于tomcat的Web应用程序,需要在Eclipse中调试该应用程序。 In the .net world the above statement when encountered will prompt the OS to attach a debugger and I can attach Visual Studio to debug. 在.net世界中,遇到上述声明时,将提示操作系统附加调试器,我可以附加Visual Studio进行调试。 I am trying to achieve the equivalent in java with eclipse 我正在尝试使用Eclipse实现Java中的等效功能

Here's an excellent article on remote debugging using Eclipse . 这是一篇有关使用Eclipse进行远程调试的出色文章。 They even have a section discussing Tomcat. 他们甚至有一节讨论Tomcat。

In general the Java program cannot tell if the JVM runs in debug mode or not, and there is no way to from your program to say that you always want to start a debugger HERE . 通常,Java程序无法确定JVM是否在调试模式下运行,并且无法从程序中说出您始终想在此处启动调试器。

You can, however, tell the DEBUGGER that you want to have a breakpoint at a given location, and you will then enter the debugger when the program reaches that spot. 但是,您可以告诉DEBUGGER,您希望在给定位置有一个断点,然后在程序到达该位置时进入调试器。


EDIT: You will need to investigate your launcher to see how you can trick it to contain the options needed to enable debugging in the JVM. 编辑:您将需要调查启动器,以了解如何诱使它包含在JVM中启用调试所需的选项。 You may also see if jvisualvm can give you the information you need as it can attach to an unprepared Sun JVM. 您可能还会看到jvisualvm是否可以为您提供所需的信息,因为它可以附加到未经准备的Sun JVM。

Here's a link that I used to debug web apps on Tomcat. 这是我用来在Tomcat上调试Web应用程序的链接。 It goes through installing Eclipse, Tomcat and Java and then setting up Tomcat to run in Eclipse. 该过程包括安装Eclipse,Tomcat和Java,然后设置Tomcat以使其在Eclipse中运行。 Towards the bottom explains how to debug a servlet in Eclipse. 往底部解释了如何在Eclipse中调试servlet。

http://www.windofkeltia.com/j2ee/wtp-tutorial.html http://www.windofkeltia.com/j2ee/wtp-tutorial.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM