Super User is a question and answer site for computer enthusiasts and power users. 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

Every time I run a java application, one of two things happen:

  • Either I lose sound in all other programs (even after quitting the java app)
  • or if some other application is already playing sound, the said java app doesn't have sound

Usually this can be fixed by running pulseaudio --kill from the command line, but it doesn't always work.

Is there a way to fix this problem?

This didn't happen before the upgrade to karmic.

Other info:

  • The java I'm using is Sun's Java
share|improve this question
What's your sound hardware? Some drivers are awesome (e.g., emu10k1) and some are better avoided (e.g., cs46xx) – Broam Dec 18 '09 at 15:26
up vote 3 down vote accepted

This is a problem that plagued me for a while -- luckily I figured out a workaround. The first thing to do is

sudo apt-get install alsa-oss

Then basically, prefix "aoss" to any java-based commands you run. So,

java app


aoss java app

And so on. This should alleviate your issues. Cheers.

share|improve this answer
this works quite well, but it's still a work around. – hasen Dec 19 '09 at 1:11
Yeah, it's a workaround, but I have a suspicion that a "real solution" would involve modifying either Java's audio classes, or PulseAudio, either of which I'm guessing are more than you would be willing to do. This works well enough and I've encountered no problems using it for years :) – Adrian Petrescu Dec 20 '09 at 3:08
+1 for a nice solution...err...workaround, sorry :D – dag729 Dec 21 '09 at 1:22

Try this:

  1. Uninstall the alsa-base package
  2. sudo update-java-alternatives -s java-6-sun
    to use Sun's java rather than default Ubuntu java install

You must have Sun's java installed on your computer.


Some links which might be useful:
Simple guide to Sound Solutions for Hardy,Intrepid and Jaunty Jackalope Users
Sound Solutions for Ubuntu 9.04 (Jaunty) Users

share|improve this answer
updated question: my java is sun's java. – hasen Dec 16 '09 at 7:45
Is it the latest version? – harrymc Dec 16 '09 at 9:07
pulseaudio --kill

Is, as you said, only a (a little annoying) work around , may be you need something more radical, in my experiments with the "TERRIBLE" linux sound management, i've found that pulseaudio is more an issue than a solution, my advice is to ERADICATE it, using a punctual (and reversible, of course) procedure, i could write it, but i've found it here:

Take this words "cum grano salis" even if was written for 8.10, trying to understand who are the parts interested on Linux audio management, maybe you can learn something. :-D

share|improve this answer

I know that is neither a workaround nor a solution, but it could help you to go one step straight to resolve the issue (at least so I hope):

It seems that Java need a sound device and so it grab one: the solution posted by Adrian Petrescu it's good. I would improve it using "aliases" in bashrc, something like "alias j='aoss java app'" could help.

Hope you could find a real solution (in such a case, I hope you'll write something upon the matter in some GREAT s because, as adrian said,

a "real solution" would involve modifying either Java's audio classes


share|improve this answer

This may not be an option for you, but OpenJDK on Ubuntu has in fact been modified to use PulseAudio by default. Switching to OpenJDK will make java sound "behave."

You could try configuring the Sun JRE to use the PulseAudio stuff from OpenJDK; the relevant configuration is in /usr/lib/jvm/java-6-openjdk/jre/lib/ and the code is in /usr/lib/jvm/java-6-openjdk/jre/lib/ext/pulse-java.jar. Copying those files to the corresponding location under /usr/lib/jvm/java-6-sun might work. Or it might not.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .