Hello everyone,


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

URL url = null;
try {
	url = new URL("file:/c:/temp/sample.wav");
	AudioClip clip = Applet.newAudioClip (url);
	clip.play();
} catch (MalformedURLException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}

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

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.

Thanks 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

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


regards,
George

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.