Free Data Structures and Algorithms Course

Subscribe below and get all best seller courses for free !!!


Subscribe to all free courses

How to Play an MP3 File in Java ?

In order to play Mp3 files in Java , you need to download  jl1.0.jar from the website After downloading put the jar into Eclipse or Netbeans buildpath and execute below code.

Program to demonstrate how to play Mp3 files in Java

package com.hubberspot.example;

import javazoom.jl.player.Player;

public class Mp3Player {
    private String filename;
    private Player player; 

    public Mp3Player(String filename) {
 this.filename = filename;

    public void play() {
 try {   
            BufferedInputStream buffer = new BufferedInputStream(
    new FileInputStream(filename));
     player = new Player(buffer);;
 catch (Exception e) {



    public static void main(String[] args) {
 Mp3Player mp3 = new Mp3Player("song.mp3");;



© 2021 Learn Java by Examples Template by Hubberspot