Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to know the process ID of a particular window. I have seen and used the Force close panel applet, and I'd like something similar that would report me the process ID of the window I select.

If a tool for this purpose exists, that'd be great. Although, I am willing even to write a simple python script if it can be done.

Edit: In a more specific case, I want to get the process ID of a java swing window. (The xprop solution some answers suggest is not working).


share|improve this question

Use xprop _NET_WM_PID and click the window you want to query.

For instance, if you run it on a gnome-terminal:

 $ xprop _NET_WM_PID
 $ pidof gnome-terminal
share|improve this answer
Thanks Egil, this seems to work for few windows, but I am trying on a java swing window, and the output comes as _NET_WM_PID: not found. Any idea? – Shrikant Sharat Apr 21 '11 at 10:54
xprop _NET_WM_PID | cut -d' ' -f3

That will give you a target, click a window and it'll give you the PID.

I'm sending the output through cut (you could use awk '{ print $3 }' instead if you like) to clean it up so you could script it into something else, if you needed to.

share|improve this answer
Please see my comment on Egil's answer, this does not work for java swing windows. Any other way to do this? – Shrikant Sharat Apr 21 '11 at 10:55

You could also open System Monitor. Switch to the Processes tab and look for your Java window.

share|improve this answer
All my java processes are listed as, well, java in that tab. How to know which process has opened which window? I couldn't find anything that shows this. – Shrikant Sharat May 3 '11 at 6:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.