Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to debug an already running Java program in Eclipse?

Tags:

java

eclipse

What I'm asking is if it's possible to do the following steps in order:

  1. Run as... Java application
  2. Let the program run until it reaches the point I want to debug
  3. Debug that program when it gets to that point.

The reason why I launch the program using "Run as..." and not "Debug as..." is because the program hangs (I suspect an infinite loop) at some point, but I'm not able to replicate it consistently. What I mean is that I can make it hang consistently, but it happens during random occasions.

For what it's worth, my program is a game and it hangs at different points in the game, which is why I can't be sure where to put a breakpoint, so it would be great if i could let it run first and then switch to debug at the point where it hangs/loops.

like image 456
heisenbergman Avatar asked Jun 12 '13 11:06

heisenbergman


1 Answers

Why don't you just execute your program with "Debug as..." without setting any breakpoint. Then, when it hangs, switch to Eclipse's debug perspective and suspend your program with the double vertical bars button?

like image 123
Nicola Musatti Avatar answered Nov 09 '22 14:11

Nicola Musatti