Blog-Archiv

Freitag, 7. März 2025

Debugging Swing JComboBox Callback Freezes Ubuntu Desktop

Such things happen really rarely. The whole desktop was completely frozen, the mouse still moved but no click caused anything, not even on the Ubuntu status bar. I use Eclipse 2024-09 with Java 21 on Ubuntu LINUX 24.04.1 LTS with Kernel 6.8.0-45-generic on a 64 bit machine.

What I was trying to do is debug a Java Swing JComboBox callback, i.e. trying to follow the source code when I chose an item from that combo box. The combo box was open, my Eclipse debugger correctly jumped to the according source line, but no mouse click or keyboard input was accepted any more by any UI control, not even the operating-system's desktop responded.

On any LINUX you can press Alt-Ctrl-F3 to get a terminal screen, login with your password and then kill the hanging Java process or Eclipse or both. The terminal commands would be:

  $ ps -ef | grep -i java
  # or maybe "ps aux ..."

The number in the second column of the text output would be the PID you need to kill then:

  $ kill PidOfProcessToKill

Mind that killing Eclipse may not remove the Java-process, but I didn't find out which one causes the problem.

With Alt-Ctrl-F2 (or maybe Alt-Ctrl-F7, try F-keys from 2 to 7) you can get back to your graphic desktop, where the input lock should not be present any more then.

But: how to debug now the Java/Swing application? I searched the Internet and found an Ubuntu forum entry from year 2009. Workaround would be to run the Java/Swing aplication with follwing VM-option:

  -Dsun.awt.disablegrab=true

You can enter this on the Eclipse Run/Debug configuration dialog on the right-side "Arguments" tab in the lower "VM arguments" text field. This worked for me. Desktop not locked any more, happy debugging. Very old Java-VM bug, never fixed.