Add pulseaudio support to sun-java6-jdk

Bug #457144 reported by Antti S. Lankila
This bug affects 19 people
Affects Status Importance Assigned to Milestone
openjdk-8 (Ubuntu)
Nominated for Karmic by Francesco Pretto
Nominated for Lucid by Francesco Pretto
sun-java6 (Ubuntu)
Nominated for Karmic by Francesco Pretto
Nominated for Lucid by Francesco Pretto

Bug Description

OpenJDK for amd64 contains the following files:


and a file with this:

# OpenJDK on Ubuntu is configured to use PulseAudio by default

Copying the files above from openjdk to sun jdk and these rows to seems to turn java6 jdk pulseaudio aware. It'd be great to see future versions of the package do this automatically.

The following is not related to the bug but describes my motivation. I need to do this because I don't get sound with OSS or ALSA applications because of routing problems with optical connection from Audigy 2 ZS that's somehow related to pulseaudio but undebugable for me. It is related to the "Optical Raw" switch, which I could toggle in the past to get alsa and oss sound working again over the digital output. However, in the karmic betas this setting can no longer be toggled with alsamixer, and thus I *must* have audio routed via pulseaudio to hear anything at all.

ProblemType: Bug
Architecture: amd64
Date: Wed Oct 21 15:26:34 2009
DistroRelease: Ubuntu 9.10
NonfreeKernelModules: nvidia
Package: sun-java6-jdk 6-15-1
 PATH=(custom, user)
ProcVersionSignature: Ubuntu 2.6.31-14.48-generic
SourcePackage: sun-java6
Uname: Linux 2.6.31-14-generic x86_64

Revision history for this message
Antti S. Lankila (alankila) wrote :
Revision history for this message
Robert W. Brewer (rwb123) wrote :

The workaround did add pulse support to a simple test app I had. It didn't ultimately work for my Sphinx4 speech recognition app however, so I had to revert to using Sun's JVM and ALSA.

Changed in sun-java6 (Ubuntu):
status: New → Confirmed
Revision history for this message
Daniel Letzeisen (dtl131) wrote :

Francesco, could you try to create an /etc/asound.conf file like the one here:
In terminal:
gksu gedit /etc/asound.conf

Then copy and paste the code below into the file. Save, quit, and reboot. See if alsa apps works properly now:
pcm.pulse {
    type pulse
ctl.pulse {
    type pulse
pcm.!default {
    type pulse
ctl.!default {
    type pulse

Revision history for this message
Francesco Pretto (ceztko) wrote :

Hello. Sorry, I forgot to subscribe to this bug so I lost your update. Tried your hint and no joy.

I usually test this problem with browser and this java web radio:

Close browser -> open browser -> open java web radio -> open any youtube video -> NO sound on youtube.

Close browser -> open browser -> open any youtube video -> open java web radio -> NO sound on java web radio.

Revision history for this message
manolo (manuel-sales) wrote :

Francesco, thanks for the advice.

The good news is that if I follow your advice it works (just copying and pulse-java.jar is enough, even if I don't modify it also works), I can play your web radio at the same time I play music with Rhythmbox

The bad news is that not everything works..

1) a java program not done by me, it works the first time a sound is played (but an icon that should change to pause after the sound is played never changes) and the second time it tryes to play the application gets frozen (I suppose the first sound never acknowledges that it has finished and some kind of lock occurs) and the only way out is to kill it.
The terminal shows this stack trace
PulseAudio Eventloop Thread
 at java.lang.Object.wait(Native Method)
 at java.lang.Thread.join(
 at java.lang.Thread.join(
 at org.classpath.icedtea.pulseaudio.PulseAudioClip.close(
 at jsound.b.f(
 at jsound.b.update(
 at org.classpath.icedtea.pulseaudio.PulseAudioLine.fireLineEvent(
 at org.classpath.icedtea.pulseaudio.PulseAudioDataLine$2.update(
 at org.classpath.icedtea.pulseaudio.Stream.underflowCallback(
 at org.classpath.icedtea.pulseaudio.EventLoop.native_iterate(Native Method)
2) A program done by me plays the sound the first time but the second not; in this case my application doesnt throw any error and there is no stack trace; anyway it seems similar to case 1.
In this case the code I wrote for the defining and loading the sound is...
    try {

      // especificar el sonido a tocar

      soundFile = new File(c.carpetaDatos + "CconfCV.wav");

      sound = AudioSystem.getAudioInputStream(soundFile); //throws UnsupportedAudioFileException, IOException

      // cargar el sonido en memoria (un Clip)

      clipConfCV = (Clip) AudioSystem.getLine(new DataLine.Info(Clip.class, sound.getFormat()));;

    } catch (javax.sound.sampled.UnsupportedAudioFileException ex) {

       c.t.traza('E', "Aplicacion", "UnsupportedAudioFileException: en sonido " + soundFile, true, false);

    } catch ( ex) {

       c.t.traza('E', "Aplicacion", "IOException: en sonido " + soundFile, true, false);

    } catch (javax.sound.sampled.LineUnavailableException ex) {

       c.t.traza('E', "Aplicacion", "LineUnavailableException: en sonido " + soundFile, true, false);



And the method for playing...
  public void ReproduceSonido(int sonido) {

    clipConfCV.setFramePosition(0); clipConfCV.start();

Revision history for this message
Francesco Pretto (ceztko) wrote : Re: [Bug 457144] Re: Add pulseaudio support to sun-java6-jdk

2010/5/8 manolo <email address hidden>:
> Francesco, thanks for the advice.

Wasn't my advice, but Antti's one. Anyway, it seems sun official jvm
isn't going to be supported long (it's have been removed from lucid
main repositories), so it's better to begin reporting bugs with
openjdk where hopefully integration with pulseaudio works better.

Revision history for this message
Craig Hewetson (craighewetson-deactivatedaccount) wrote :

I have a workaround (found on this site: ) to get java sound to "use" pulseaudio

Rename your existing java executable to java.bin and drop an executable script called java in the directory with the following content:

padsp /usr/lib/jvm/java-6-sun/jre/bin/java.bin "$@"

Now I can run my audio player (rhythmbox) and play audio through my java application (java sound)

Revision history for this message
Rob Frohne (frohro) wrote :

Hi All,

I don't know how I missed this bug report when I made this one:

Anyway, there is a patch included in that one that solves the problem nicely.

The maintainers seem reluctant to include it in the distribution, because it isn't totally clear if patches to sunjava6 are allowed. I think they are based on the license saying that the README files contain the details about what can be and can't be patched, and based on the README content, however, I'm not a lawyer or the maintainer, so my opinion probably doesn't count.


Revision history for this message
Sylvestre Ledru (sylvestre) wrote :

Rob, I am sorry but there is no way we would do something like you are proposing in bug 685125.

I see (at least) two blocking reasons:
* OpenJDK is GPL while sun-java-6 is not at all (it is proprietary). This would violate the GPL.
* You are coping binary from a package to other without any certitude about the binary compatibility. (this work would requires a total synchronization between the openjdk and proprietary on the packaging side which does not exist at all).

Revision history for this message
Daniel Letzeisen (dtl131) wrote :

This should probably be marked as Won't Fix since Ubuntu is no longer licensed to distribute Sun/Oracle Java.

Changed in sun-java6 (Ubuntu):
status: Confirmed → Won't Fix
Revision history for this message
Václav Šmilauer (eudoxos) wrote :

Just for the record, this seems to be broken still (2015) with Oracle's Java. Happy customers are the most important thing...?!

Revision history for this message
wolfger (wolfger) wrote :


Revision history for this message
Tiago Stürmer Daitx (tdaitx) wrote :

Unfortunately, we cannot work on this bug because your description didn't include enough information on how this affects OpenJDK-8. We'd be grateful if you would then provide a more complete description of the problem. For now settings this as invalid for OpenJDK-8.

Changed in openjdk-8 (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers