944,120 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 10794
  • Java RSS
Jan 4th, 2005
0

Question about java.lang.SecurityException

Expand Post »
Hello everyone,


I have written the following simple program to play a local .wav file.

Java Syntax (Toggle Plain Text)
  1. URL url = null;
  2. try {
  3. url = new URL("file:/c:/temp/sample.wav");
  4. AudioClip clip = Applet.newAudioClip (url);
  5. clip.play();
  6. } catch (MalformedURLException e) {
  7. // TODO Auto-generated catch block
  8. e.printStackTrace();
  9. }

But when running the program, the following exception will be thrown,

Exception in thread "main" java.lang.VerifyError: java.lang.SecurityException: java.applet.AudioClip - protected system package 'java.applet'
at java.lang.Class.verify(Class.java:259)
at java.lang.Class.initialize(Class.java:315)

Does anyone know how to solve the issue?


Thanks in advance,
George
Reputation Points: 11
Solved Threads: 0
Junior Poster
George2 is offline Offline
189 posts
since Nov 2004
Jan 4th, 2005
0

Re: Question about java.lang.SecurityException

Don't use applet classes outside applets, they won't work outside the applet sandbox.

If this is an applet, remember you can not access ANY resource that doesn't reside on the same server as the one from which the applet main class was loaded.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jan 4th, 2005
0

Re: Question about java.lang.SecurityException

Thanks jwenting,


Quote originally posted by jwenting ...
Don't use applet classes outside applets, they won't work outside the applet sandbox.

If this is an applet, remember you can not access ANY resource that doesn't reside on the same server as the one from which the applet main class was loaded.
I am not writing an Applet, but a Java application. I simply want to use the ability of playing sound of Applet (Interface AudioClip) in my Java application to save my time of writing sound player. So maybe your approach can not work in my situation.

I am wondering whether it is possible to make my Java application be able to use sound playing ability of class Applet?


regards,
George
Reputation Points: 11
Solved Threads: 0
Junior Poster
George2 is offline Offline
189 posts
since Nov 2004
Jan 10th, 2005
0

Re: Question about java.lang.SecurityException

Thanks for all the people who helped me on this thread.


regards,
George
Reputation Points: 11
Solved Threads: 0
Junior Poster
George2 is offline Offline
189 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: altering a link
Next Thread in Java Forum Timeline: Looking for J2ME audio or video player





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC