How to cleanly shutdown Eclipse from Linux command line? How to cleanly shutdown Eclipse from Linux command line? linux linux

How to cleanly shutdown Eclipse from Linux command line?


I figured this out with the help of gigi's answer and another question. You're going to need the wmctrl and xdotool utilities from your package manager.

Unless you're running in a terminal emulator on the same display, you need to set the right display:

$ export DISPLAY=:0.0

Then (irrelevant windows elided from example):

# List windows$ wmctrl -l...0x030000fa  0 kcirb Java - Eclipse# Tell Eclipse window to close gracefully$ wmctrl -c eclipse# Darn, there's a confirmation dialog$ wmctrl -l...0x030000fa  0 kcirb Java - Eclipse 0x03003c2d  0 kcirb Confirm Exit # Send return key to the window$ xdotool key --window 0x03003c2d Return

Worked for me on Ubuntu 12.04, at least.

EDIT: See Scarabeetle's answer for the tweaks you need to make it work from a script.


Not enough reputation to comment on pidge's answer above...It almost works, but I needed to wait for some Gnome3 animation to finish and then give focus to the "Confirm Exit" window:

export DISPLAY=:0.0        # Do this in main X sessionwmctrl -c "Eclipse SDK"    # Close main windowsleep 1                    # Wait for animationwmctrl -a "Confirm Exit"   # Give focus to the dialog# Send a Return keypress to press the OK buttonxdotool key --window $(xdotool search "Confirm Exit") Return


Try killing java process(es). Do ps -ea | grep java