I'm trying to develop a java application for the raspberry pi that will play mp3s.

I wrote a simple program to see if it would work using JLayer

Code for the app is like this:

public static void main(String[] args) {        
    Player player = null;

    try {
        FileInputStream fis = new FileInputStream("song.mp3");
        BufferedInputStream bis = new BufferedInputStream(fis);
        player = new Player(bis);
    } catch (Exception e) {

    try {
    } catch (JavaLayerException e) {

The program runs on windows but on the pi when creating the new player object I am getting the exception:

Cannot create AudioDevice

Has anyone been able to get JLayer working on the pi?

I'm using the latest Soft-float Debian “wheezy” image with the Orcale JVM.

  • You're better off using printStackTrace() as it gives a lot more information than getMessage() when it comes to debugging. I've just tried the above and I get the same error (openjdk6). I changed it to printStackTrace() and I get: java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format PCM_SIGNED 22050.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian is supported. Not sure how to fix this though.
    – Munkeh
    Oct 28, 2012 at 23:00
  • After some searching, I found this thread which should help: raspberrypi.stackexchange.com/questions/1337/…
    – Munkeh
    Oct 28, 2012 at 23:12
  • I would say that this is the problem (again).
    – Jivings
    Oct 29, 2012 at 7:50
  • So did you have any luck with openjdk7? I run arch-arm on my pi so I can't test. As above though, you're gonna get poor performance decoding mp3 in real time. You're better off running a program written in C (mpg123, etc.) for performance.
    – Munkeh
    Oct 29, 2012 at 22:36

1 Answer 1


I got this working. I had installed the Oracle JRE but it wouldn't play, but when I installed the Oracle JDK the mp3 played ok. The performance is good which was a nice surprise!

  • Same here - downloaded ejre-7u21-fcs-b11-linux-arm-vfp-client_headless-04_apr_2013.tar.gz and it couldn't find audio device, so I changed to JDK jdk-7u21-linux-arm-sfp.tar.gz (taken from usual JDK download page) and it worked.
    – mvmn
    Aug 16, 2013 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.