wood burning stoves 2.0*
The moose likes Applets and the fly likes Exception trying to play audio file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Exception trying to play audio file" Watch "Exception trying to play audio file" New topic
Author

Exception trying to play audio file

Joachim Olga
Greenhorn

Joined: May 15, 2004
Posts: 9
When trying to play a sound through my applet I get the following exception. How can I make it play the sound?


Exception in thread "AWT-EventQueue-18" java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at java.io.Win32FileSystem.getUserPath(Unknown Source)
at java.io.Win32FileSystem.resolve(Unknown Source)
at java.io.File.getAbsolutePath(Unknown Source)
at java.io.File.toURL(Unknown Source)
at Hangman.playSound(Hangman.java:117)
at Hangman.success(Hangman.java:97)
at Hangman.makeGuess(Hangman.java:70)
at Hangman.access$100(Hangman.java:12)
at Hangman$3.actionPerformed(Hangman.java:160)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


This is the code that creates the exception:

Joachim Olga
Greenhorn

Joined: May 15, 2004
Posts: 9
Aha...


Instead of new File and toURL

getClass().getResource("myWav.wav");

...and there you got your URL.

[ February 09, 2005: Message edited by: Joachim Olga ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Exception trying to play audio file
 
Similar Threads
java.io.StreamCorruptedException: invalid stream header: C2ACC3AD
Getting error Incompatible magic value 1784772193 in class file
null pointer exception when clicking on JCheckbox
Extracting the contents of the String
unexpected exception:please help