Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cleanly shutdown Eclipse from Linux command line?

Is there a way to shutdown Eclipse cleanly from the command line, such that files and workspaces are saved? kill -3 doesn't do anything. kill -1 and kill -15 (default) causes Eclipse to exit abruptly with JVM termination popup. kill -9 does the same thing.

The use case is that I'm working remotely on a machine with Eclipse loaded on it, and I want to save memory by closing Eclipse, but I want Eclipse to save its state first.

I could use VNC or some alternative desktop sharing software, but that's really heavy-weight, and I'd much prefer a command line solution.

EDIT: System info: RHEL5.1 64-bit using GNOME

like image 389
Maian Avatar asked Jun 17 '11 20:06

Maian


People also ask

How do I force quit Eclipse in Linux?

How do I force quit the application? open a terminal, type xkill + Return. Then click on the application's window.

How do you end an eclipse?

viswamy2k, I am afraid, I do not know any way to exit the eclipse / myeclipse workbench from command line. You need to do that from the IDE. You can use the shortcut key – [Alt] + F + X or using menu option – File > Exit.


1 Answers

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.

like image 159
pidge Avatar answered Oct 05 '22 11:10

pidge