title: Return the active window title in java
body: <p>Using On linux using java/groovy I wish to retrieve the name of the active window and store it in a string, but I can't get my command to work - this just returns an empty string.</p>
  
  <pre><code>import groovy.swing.SwingBuilder
  import javax.swing.JFrame
  
  curText = "xdotool getwindowname \$(xdotool getwindowfocus)".execute().text
  
  new SwingBuilder().edt { optionPane().showMessageDialog(null, '#'+curText+'#') }
  </code></pre>