AccessControlException

I am trying to play a wav file in my applet game. But I get a runtime error that states I do not have access to the file. How do I get around this?

The error:

java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)

at java.security.AccessController.checkPermission(AccessController.java:401)

at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)

at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1276)

at java.lang.System.getProperty(System.java:573)

at java.io.Win32FileSystem.getUserPath(Win32FileSystem.java:272)

at java.io.Win32FileSystem.resolve(Win32FileSystem.java:288)

at java.io.File.getAbsolutePath(File.java:459)

at java.io.File.toURL(File.java:572)

at Game1945.paint(Game1945.java:262)

at javax.swing.JApplet.update(JApplet.java:143)

at sun.awt.RepaintArea.paint(RepaintArea.java:169)

at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)

at java.awt.Component.dispatchEventImpl(Component.java:3678)

at java.awt.Container.dispatchEventImpl(Container.java:1627)

at java.awt.Component.dispatchEvent(Component.java:3477)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

my code that is erroring:

File f3 = new File("dbomb.wav");

try

{

AudioClip bomb = JApplet.newAudioClip(f3.toURL());

bomb.loop();

}

catch(IOException e){}

[2004 byte] By [javaGamer2Da] at [2007-10-1 1:05:15]
# 1
Instead of new File and toURLgetClass().getResource("/dbomb.wav");...and there you got your URL. (The wav should be also in that jar)
oNyxa at 2007-7-8 1:23:23 > top of Java-index,Other Topics,Java Game Development...