~ PulseAudio Support for Sun Java 6 on Ubuntu» By Joren on Friday 27 May 2011
This article describes how to make sun-java6 play nice with the PulseAudio sound sytem on Ubuntu with an x64 processor architecture. With some changes the method should also work with other operating systems and other platforms.
The default way sun-java6 operates with respect to sound on Ubuntu is, well unrespectfull. When playing audio it claims an audio device, which then can not be used any more by other applications trying to access the same device. This is far from ideal. Also changing audio interfaces (by e.g. plugging in a USB audio interface) goes wrong most of the time.
These problems are addressed by PulseAudio and there is a way to make sun-java6 aware of PulseAudio on Ubuntu. The OpenJDK does this automatically but it has some other, unrelated, issues. If you want to use PulseAudio with java6 on Ubuntu x64 you need copy pulse-java.jar and platform dependent libpulse-java.so file to correct JVM directories. To make it easy you can execute these commands:
wget http://tarsos.0110.be/attachment/cons/255/libpulse-java.so sudo cp libpulse-java.so /usr/lib/jvm/java-6-sun/jre/lib/amd64 wget http://tarsos.0110.be/attachment/cons/256/pulse-java.jar sudo cp pulse-java.jar /usr/lib/jvm/java-6-sun/jre/lib/ext
From this moment on the “PulseAudio Mixer” is available for Java applications. Sharing, switching and assigning audio devices to Java programs is as a result smooth. To use the PulseAudio Mixer by default you need to change sound.properties which can be found at
/usr/lib/jvm/java-6-sun/jre/lib/sound.properties. Details can be found here.