File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Question about java.lang.SecurityException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about java.lang.SecurityException" Watch "Question about java.lang.SecurityException" New topic
Author

Question about java.lang.SecurityException

George Lin
Ranch Hand

Joined: Jan 11, 2005
Posts: 125
Hello everyone,


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



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
Barry Higgins
Ranch Hand

Joined: Jun 05, 2003
Posts: 89
As far as I know the problem is that you are running an applet .. the only way I know around this is to sign the applet to allow access to the underlying file structure!
You can check that on the sun's website.
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
I don't use applets but what if you changed the URL for the WAV to be an http URL? I think the restriction in applets is related to local file access.
George Lin
Ranch Hand

Joined: Jan 11, 2005
Posts: 125
Thanks Barry,


Originally posted by Barry Higgins:
As far as I know the problem is that you are running an applet .. the only way I know around this is to sign the applet to allow access to the underlying file structure!
You can check that on the sun's website.


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 how to make my Java application be able to use sound playing ability of class Applet?


regards,
George
George Lin
Ranch Hand

Joined: Jan 11, 2005
Posts: 125
Thanks Greg,


Originally posted by Greg T Robertson:
I don't use applets but what if you changed the URL for the WAV to be an http URL? I think the restriction in applets is related to local file access.


Your reply is very helpful. I am wondering how to changed the URL for the WAV to be an http URL so that I can restrict the access to local file system. Can you show me some sample source codes?


regards,
George
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
According to this, there is a simple way to play audio files in an application without using the methods from Applet.

HTH

Layne


Java API Documentation
The Java Tutorial
George Lin
Ranch Hand

Joined: Jan 11, 2005
Posts: 125
Thanks Layne,


Originally posted by Layne Lund:
According to this, there is a simple way to play audio files in an application without using the methods from Applet.

HTH

Layne


The article is very helpful. I have tried the sample application provided in this article on my platform, but it does not work (JVM has no output and no sound is heard). I am wondering what is the trouble? Do you know some other approaches to play sound?


regards,
George
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about java.lang.SecurityException