6

I just installed Fedora 12 and after downloading and running the Java Sound Demo I get exceptions. If I run just a vanilla Java program that plays a .wav file it runs silently with no sound and no exceptions.

Every other app seems to play sound. I also took some advice from this thread in the Ubuntu forums which almost seemed to work. (Installing aoss got rid of the initial exceptions in the sound demo but I still hear nothing when I play.)

I'm getting frustrated by the individual hoops I have to go through to eek sound out of my speakers when running Java apps on Linux platforms!

Can somebody help me figure out what's wrong?

4 Answers 4

3

I've found my own answer. From the list of things you should'a learned in Kindergarten:

If you have a second sound card in your box, like one that didn't originally work with Linux and caused you to start using the built-in support on your motherboard, then you will probably not realize that Java audio support goes to the sound card you aren't using. What that means is that even though all of my other audio was going to the card I activated using the mixer in the system tray, Java decided to route its audio to the other card.

So all along the audio actually was playing happily. I just couldn't hear it because it was playing on the Sound Blaster XFi card and I had my speaker plugged into the motherboard's audio port. I apologize if I sound smug but I'm frustrated and not having much fun especially after seeing that a serious issue can get voted down leaving the answer to that serious issue hidden to others facing the same woes.

I'm not slamming Linux, Fedora or Java. I'm just trying to understand why something that should be simple has caused such complicated research. I figured this out almost by accident as an article tipped me off that Java audio support might actually pick a different driver to route audio.

2
  • Hardly transferable question and answer to other users, and vital information for answer not given in question
    – Cookie
    Dec 20, 2011 at 1:17
  • I don't follow. The vital information was that my box had 2 sound cards installed. Linux and all of the apps installed were correctly routing to the motherboard sound card that had speakers connected while Java defaulted audio routing to the secondary Sound Blaster sound card where nothing was connected. Plugging my speakers into the sound blaster card fixed the problem. I recall there was a way to route Java audio to the other card as well but its been so long that I cannot remember.
    – Cliff
    Dec 20, 2011 at 18:16
2

Curiously enough, a fix for me was to add a config file ~/.alsoftrc with the contents:

[pulse]
allow-moves=yes

The java application in my situation (Minecraft on Xubuntu 14.04 LTS) refused to use the audio output that actually worked (digital audio hdmi) and instead defaulted to something that didn't exist, analog audio.

Just putting this here for the next person wondering why java won't do sound correctly.

1
  • 1
    This solved it for me; crazy that this is still an issue 8 years later.
    – Umopepisdn
    Nov 20, 2022 at 22:34
0

I have the same problem. When you use another program that uses sound before you start your java program that uses sound, your java sound won't work. It looks like that java sound is not using the Alsa mixer but tries to use the hardware after the Alsa mixer. Only a restart resolves the problem then.

0

I had the same problem with Raspberry Pi 3 B with the Oracle JAVA 8. I have added a new audio card. Then as the following procedure, the default audio card has changed:

nano /usr/share/alsa/alsa.conf

Change the defaults.ctl.card 0 and defaults.pcm.card 0 to defaults.ctl.card 1 defaults.pcm.card 1 then save alsa.conf file.

reboot

In the Raspbian Buster (not sure it's related to the Buster) I have run my Java tester code but the problem still stay tuned

Finally, by the procedure below, I disabled the default onboard audio card on boot state.

nano /boot/config.txt

Comment the dtparam=audio=on. I mean, change dtparam=audio=on to #dtparam=audio=on.


References:

You must log in to answer this question.