27

I have a problem while debugging in IntelliJ IDEA, it hangs in debug mode on break point in listeners in javafx application. I tried to increase heap space, but it's not help. Maybe someone had such problem too, please, suggest me what to do.

vikki
  • 321
  • 5
  • 13

2 Answers2

65

Set this as a VM parameter:

-Dsun.awt.disablegrab=true

It will mess up drag-and-drop, and leave an artifact on your screen while the debugger is paused - but it will let you debug. It happens whenever you block the JavaFX thread.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
user2163960
  • 1,871
  • 19
  • 22
1

This can happen for a simple reason: The application has a lock on the desktop, for example a modal dialog or a popup or an open menu. Then it stops in a breakpoint. This notifies the IDE. Now the IDE tries to do something on your desktop but can't since the application still has a lock on the whole desktop -> deadlock.

You can use a tool like Chronon which records the whole program and lets you move back and forth on the timeline.

The last option is logging or poor man's debugger (System.out) instead.

[EDIT]

it's hard to check with System.out which of 20 parameters not equal.

It's actually pretty easy:

System.out.println("check");
if(!a1.equals(b2)) System.out.println(a1+"!="+b1);

Then duplicate the last line. That way, you will only get output when something is actually interesting (and not for the 19 equal parameters). Add some patterns to the output if you can't distinguish aX from aY (i.e. both are true):

if(!a1.equals(b2)) System.out.println("a1:"+a1+"!="+b1);
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • If I have to check for equals two object with 20 parameters, and it's return false, but I actually expected true, it's hard to check with System.out which of 20 parameters not equal. Also none of my colleagues don't have such problem in debug in listeners, but they also don't have any idea what's wrong, we all have the same hardware, OS and environment. – vikki Jan 09 '15 at 16:21
  • I like the explanation here, but not the solution. I'm trying to make my debugger work on Ubuntu, I need it to work. I don't have these issues with the same IDE and same application on my OSX machine. What are my options? – craigmiller160 Apr 01 '16 at 18:46
  • @user2223059 You can use the command line option in the accepted answer, use logging, [Chronon](http://chrononsystems.com/) or you can create a new, lock-free desktop for Linux. – Aaron Digulla Apr 02 '16 at 15:07