简体   繁体   中英

Launching Eclipse as a debugger

What's the equivalent of

System.Diagnostics.Debugger.Break();

in the Java world?

Purpose: I have a tomcat based webapp launched by a custom build tool and need to debug the application in 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. I am trying to achieve the equivalent in java with eclipse

Here's an excellent article on remote debugging using Eclipse . They even have a section discussing 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 .

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.


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. You may also see if jvisualvm can give you the information you need as it can attach to an unprepared Sun JVM.

Here's a link that I used to debug web apps on Tomcat. It goes through installing Eclipse, Tomcat and Java and then setting up Tomcat to run in Eclipse. Towards the bottom explains how to debug a servlet in Eclipse.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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