title: How can I make my Java application with audio play nice in Linux?
body: <p>I have a Java application whose UI relies heavily on audio. On Windows and OS X, everything works fine; on Linux, however, the application requires exclusive access to the sound device, a <code>LineUnavailableException</code> is thrown and no sound is heard. I'm using Kubuntu 9.10.</p>
  
  <p>This means that no other application can play audio while the program is running, and can't even be holding an audio device when the program starts. This is naturally unacceptable. </p>
  
  <p>Here is the code I'm using to play audio:</p>
  
  <pre><code>AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file);
  
  Clip clip = AudioSystem.getClip();
  clip.open(audioInputStream);
  
  clip.start();
  
  this.wait((clip.getMicrosecondLength() / 1000) + 100);
  
  clip.stop();
  </code></pre>
  
  <p>Am I doing something wrong? Is using Java to play audio in Linux a lost cause?</p>