Hi everyone!
I’m working on the game using .tmx TiledMap. The standalone version works without a problem. When I try to run my game as an applet, it fails to load the tileset image ( /img/tiles2et.png) of the TiledMap (/map/empty.tmx) :
Starting real applet
Done loading
Mon Jun 11 18:37:12 EDT 2012 INFO:Starting display 800x600
Mon Jun 11 18:37:12 EDT 2012 INFO:Use Java PNG Loader = true
WARNING: Found unknown Windows version: Windows 7
Attempting to use default windows plug-in.
Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
Mon Jun 11 18:37:12 EDT 2012 INFO:Found 3 controllers
Mon Jun 11 18:37:12 EDT 2012 INFO:0 : Logitech USB Headset
Mon Jun 11 18:37:12 EDT 2012 INFO:1 : Logitech USB Keyboard
Mon Jun 11 18:37:12 EDT 2012 INFO:2 : Logitech USB Keyboard
Mon Jun 11 18:37:12 EDT 2012 ERROR:access denied ("java.io.FilePermission" ".\img\..\img\tiles2et.png" "read")
java.security.AccessControlException: access denied ("java.io.FilePermission" ".\img\..\img\tiles2et.png" "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.checkRead(Unknown Source)
at java.io.File.exists(Unknown Source)
at org.newdawn.slick.util.FileSystemLocation.getResourceAsStream(FileSystemLocation.java:52)
at org.newdawn.slick.util.ResourceLoader.getResourceAsStream(ResourceLoader.java:61)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:169)
at org.newdawn.slick.Image.<init>(Image.java:196)
at org.newdawn.slick.tiled.TileSet.<init>(TileSet.java:113)
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:447)
at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
at zis.MapGenerator.generateEmptyMap(MapGenerator.java:34)
at zis.MapGenerator.<init>(MapGenerator.java:26)
at zis.PlayState.init(PlayState.java:72)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
at org.newdawn.slick.AppletGameContainer$Container.initApplet(AppletGameContainer.java:272)
at org.newdawn.slick.AppletGameContainer$ContainerPanel.initGL(AppletGameContainer.java:229)
at org.newdawn.slick.AppletGameContainer$ContainerPanel.start(AppletGameContainer.java:216)
at org.newdawn.slick.AppletGameContainer$1.run(AppletGameContainer.java:92)
Mon Jun 11 18:37:12 EDT 2012 ERROR:Failed to parse tilemap
org.newdawn.slick.SlickException: Failed to parse tilemap
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:480)
at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
at zis.MapGenerator.generateEmptyMap(MapGenerator.java:34)
at zis.MapGenerator.<init>(MapGenerator.java:26)
at zis.PlayState.init(PlayState.java:72)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
at org.newdawn.slick.AppletGameContainer$Container.initApplet(AppletGameContainer.java:272)
at org.newdawn.slick.AppletGameContainer$ContainerPanel.initGL(AppletGameContainer.java:229)
at org.newdawn.slick.AppletGameContainer$ContainerPanel.start(AppletGameContainer.java:216)
at org.newdawn.slick.AppletGameContainer$1.run(AppletGameContainer.java:92)
Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" ".\img\..\img\tiles2et.png" "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.checkRead(Unknown Source)
at java.io.File.exists(Unknown Source)
at org.newdawn.slick.util.FileSystemLocation.getResourceAsStream(FileSystemLocation.java:52)
at org.newdawn.slick.util.ResourceLoader.getResourceAsStream(ResourceLoader.java:61)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:169)
at org.newdawn.slick.Image.<init>(Image.java:196)
at org.newdawn.slick.tiled.TileSet.<init>(TileSet.java:113)
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:447)
... 9 more
I check multiple time and the two file are in the ZIS.jar. I also try sign my jar and I still get the same result.
I try running loading the map using Stream and I get the same error:
// Without Stream
map = new TiledMap( "map/empty.tmx", true);
// With Stream
map = new TiledMap( Thread.currentThread().getContextClassLoader().getResourceAsStream("map/empty.tmx"), "img/");
// or
map = new TiledMap( Thread.currentThread().getContextClassLoader().getResourceAsStream("map/empty.tmx"));
Thanks you in advance.