Java kills sound on Karmic

1

1

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

hasen

Posted 2009-12-10T20:45:07.737

Reputation: 4 556

What's your sound hardware? Some drivers are awesome (e.g., emu10k1) and some are better avoided (e.g., cs46xx) – Broam – 2009-12-18T15:26:56.143

Answers

3

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

becomes

aoss java app

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

Adrian Petrescu

Posted 2009-12-10T20:45:07.737

Reputation: 2 728

this works quite well, but it's still a work around. – hasen – 2009-12-19T01:11:34.070

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 – 2009-12-20T03:08:32.847

+1 for a nice solution...err...workaround, sorry :D – dag729 – 2009-12-21T01:22:11.627

0

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/sound.properties 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.

Brian Gruber

Posted 2009-12-10T20:45:07.737

Reputation: 436

0

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.

EDIT

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

harrymc

Posted 2009-12-10T20:45:07.737

Reputation: 306 093

updated question: my java is sun's java. – hasen – 2009-12-16T07:45:36.997

Is it the latest version? – harrymc – 2009-12-16T09:07:58.530

0

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:

http://www.ubuntugeek.com/how-to-remove-pulse-audio-ubuntu-810-intrepid-ibex.html

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

Акула

Posted 2009-12-10T20:45:07.737

Reputation: 183

0

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): http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/

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

Regards

dag729

Posted 2009-12-10T20:45:07.737

Reputation: 1 894