Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Error with code to implement sound

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error with code to implement sound

    Hi,

    I'm trying to implement sound into my program. I want it so when a button is clicked the sound will play however i seem to be getting an unusual error when i'm importing sound utilities and the same error appears when i'm writing the code to do with the sound.

    import sun.audio.AudioData;
    import sun.audio.AudioPlayer;
    import sun.audio.AudioStream;

    The error that appears for each is:
    "Access restriction: The type AudioData is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar"
    "Access restriction: The type AudioPlayer is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar"
    "Access restriction: The type AudioStream is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar"

    Hope somebody as an idea as to what it could mean and i how i could resolve this.

    Thank you for reading,
    Luke.
    Last edited by LukeDavison; December 4th, 2011 at 02:13 PM.


  2. #2
    Junior Member
    Join Date
    Nov 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error with code to implement sound

    ::::UPDATE:::::

    I've now solved this, if anyone has any trouble in the future this is the fix:

    In eclipse go to: Window > Preferences > Java > Compiler > Errors/Warnings > Deprecated and restricted API > Forbidden reference (access rules) > set it to ‘Warnings’

Similar Threads

  1. Code is giving an error in console, but there are no errors apparent in the code!
    By JamEngulfer221 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2011, 09:30 PM
  2. Source Code to Implement Circular Queue in Java
    By rainbow9 in forum Java Programming Tutorials
    Replies: 0
    Last Post: August 20th, 2011, 03:30 AM
  3. [SOLVED] Compiled .jar won't work (Error-sound)
    By Fermen in forum Object Oriented Programming
    Replies: 2
    Last Post: March 31st, 2011, 06:24 PM
  4. Error with code
    By JJTierney in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 4th, 2010, 05:23 PM