October 27, 2024
Chicago 12, Melborne City, USA
java

How can I fix this “package X does not exist” and import the JLayer lib in a Java with Ant NetBeans IDE 22 project?


so it’s my first time trying to use an external library in IDE NetBeans 22 and I’m trying to use the JLayer external library to make an app in Java to play an animal sound (mp3 format) when I press an specific JButton. The main problem that I have it’s when I try to compile the project via cmd and I have the next compiling errors:

enter image description here

To give y’all more context about my problem I downloaded a .jar file named as "jl1.0.1.jar" and I imported it in a project with Ant in the previous IDE named (NetBeans) to use the ./lib in the project to import the .jar file. In the section Properties > Libraries of the Ant project I have the next settings:

Here I just added the .jar file placed in the ./lib path of the Ant project
This is the specific path of the .jar file

And finally this is the piece of code where I’m trying to use the JLayer library:

package javaappapi;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.advanced.AdvancedPlayer;

public class ReproducirSonido 
{
    public void playAnimalSound(String path)
    {
        try
        {
            FileInputStream archivoMP3 = new FileInputStream(path);
            AdvancedPlayer reproductor = new AdvancedPlayer(archivoMP3);
            reproductor.play();
        }
        catch(FileNotFoundException | JavaLayerException e)
        {
            System.out.println(e.getMessage());         
        }     
    }    
}

As I said in the beginning of this message, it’s my first time trying to import and use an external lib so be patient with me, I hope I included all the details of my problem and I’ll be waiting for your help.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video