-1

I use Eclipse Juno and receive the following error:

Access restriction:The type AudioPlayer is not accessible due to restriction 
    on required library C:\Program\Files\Java\jre6\lib\rt.jar

It's very similar for AudioStream and AudioData.

How can I resolve these errors?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 5
    Possible duplicate?: http://stackoverflow.com/questions/860187/access-restriction-on-class-due-to-restriction-on-required-library-rt-jar – Andrew Martin Aug 10 '13 at 15:19
  • This has nothing to do with audio. – wchargin Aug 10 '13 at 15:24
  • *"It's very similar for `AudioStream` and `AudioData`."* What, in being not part of the (public) JRE of either Java 6 or 7? Don't use the `com` or `sun` classes. The compiler should be warning you of the same. – Andrew Thompson Aug 10 '13 at 15:26
  • This question appears to be off-topic because it is about Eclipse and not code written with it. If it *is* about software developed using Eclipse, we need to see some code here. – marko Aug 10 '13 at 17:53

1 Answers1

0

Have you tried AudioClip?

public static final Sound sound= new Sound("/sound.wav");

private AudioClip clip;

private Sound(String name) {
    try {
        clip = Applet.newAudioClip(Sound.class.getResource(name));
    } catch (Throwable e) {
        e.printStackTrace();
    }
}

public void play() {
    try {
        new Thread() {
            public void run() {
                clip.play();
            }
        }.start();
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Jaspreet
  • 167
  • 1
  • 13
  • Java has had [`Clip`](http://docs.oracle.com/javase/7/docs/api/javax/sound/sampled/Clip.html) from the Java Sound API since **Java 1.3**. Further, `Clip` does not require a separate `Thread` to run. Try to drag yourself, kicking and screaming, into the 3rd millennium. – Andrew Thompson Aug 10 '13 at 16:03