Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Deploying madness w/ applets  (Read 4344 times)
0 Members and 1 Guest are viewing this topic.
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Posted 2011-11-21 03:20:31 »

Hey guys!

I know this one has been up before, but since the search function is crap... The rest you know.

I want to deploy my application w/ slick2d as an applet. I followed the nice tutorial on NinjaCave and it all works fine. Except, my game is not signed, and it can therefore not reach my resources, which is in the same jar.
So, either I change the way resources are loaded:
1  
2  
tilesheet = new SpriteSheet("res/tileset.png", TILE_WIDTH, TILE_HEIGHT);
background = new Image("res/background.png");

or, I sign the thing. After tons of looking around, it seems that signing is not exctly the easest thing in the world. It also seams that I need to register, and all kinds of legal things to do this, and I just can't believe that.

So, what would be the easiest? Is there an easy way to sign my game, to gain acces?
Is there an easy way to load resources, that I don't know of?

Offline gbeebe

Senior Member


Medals: 5
Projects: 1



« Reply #1 - Posted 2011-11-21 03:30:39 »

I hope someone comes along and says that Signing a jar isn't that hard and explains EXACTLY how to do it, 'cause yea, I don't get it either.

Does this work?

1  
2  
3  
URL inMyJar = getClass().getResource("res/");
Image background;
background = getImage(inMyJar, "background.png");


I don't use Slick2d (I'm assuming that's where the SpriteSheet() comes from) but perhaps there is a way to load an image and convert it to a SpriteSheet?
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #2 - Posted 2011-11-21 04:02:37 »

I hope someone comes along and says that Signing a jar isn't that hard and explains EXACTLY how to do it, 'cause yea, I don't get it either.

Does this work?

1  
2  
3  
URL inMyJar = getClass().getResource("res/");
Image background;
background = getImage(inMyJar, "background.png");


I don't use Slick2d (I'm assuming that's where the SpriteSheet() comes from) but perhaps there is a way to load an image and convert it to a SpriteSheet?

I can't initialize an Image that way. It needs to have the string reference. http://slick.cokeandcode.com/javadoc/

I've tried to create a keystore, and signing and verifying my game.jar , but I still get the permission-error, even when clicking yes in the permissions box. Even though I typed in all my information when prompted during signing it appears as UNKNOWN, and none of it is showed.
1  
2  
3  
keytool -genkey -alias madshorndrup -keystore madskeystore
jarsigner -keystore madskeystore skrollr.jar madshorndrup
jarsigner -verify skrollr.jar

The whole process runs smoothly, and I looked to check I was getting the signature in the jars.

EDIT: With signing, I still get this error:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
java.security.AccessControlException: access denied (java.io.FilePermission .\res\actors\spritesheet.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)8/
   at org.newdawn.slick.Image.<init>(Image.java:196)
   at org.newdawn.slick.SpriteSheet.<init>(SpriteSheet.java:129)
   at org.newdawn.slick.SpriteSheet.<init>(SpriteSheet.java:115)
   at org.newdawn.slick.SpriteSheet.<init>(SpriteSheet.java:102)
   at com.javadaemon.skrollr.util.ResourceManager.initGraphics(ResourceManager.java:135)
   at com.javadaemon.skrollr.util.ResourceManager.init(ResourceManager.java:41)
   at com.javadaemon.skrollr.util.ResourceManager.<init>(ResourceManager.java:37)
   at com.javadaemon.skrollr.util.ResourceManager.getRessourceManager(ResourceManager.java:30)
   at com.javadaemon.skrollr.GameMain.init(GameMain.java:45)
   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)

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2011-11-21 05:45:27 »

Maybe it's not accessing the right file. Try using a forward slash ('/') at the beginning of the path to signify the root of the jar.
Also you do not need to sign a jar to be able to access resources inside it. However you do need to sign the jar to access files on the client's file system AND to be able to load native code (which you must do to use Slick2D/LWJGL).

Offline pitbuller
« Reply #4 - Posted 2011-11-21 07:36:23 »

Maybe it's not accessing the right file. Try using a forward slash ('/') at the beginning of the path to signify the root of the jar.
Also you do not need to sign a jar to be able to access resources inside it. However you do need to sign the jar to access files on the client's file system AND to be able to load native code (which you must do to use Slick2D/LWJGL).
But lwjgl applet jar is allready signed and do not need own signing if those all only native files needed.
Offline thaaks

Junior Member


Medals: 1
Projects: 1



« Reply #5 - Posted 2011-11-21 10:18:31 »

I agree with pitbuller. Signing your own jars is not required. The LWJGL jars are signed and that's sufficient.
It must be a different problem.
My "StarCleaner" game runs as an applet and I didn't sign a single jar file. All resources (images, sheets, etc.) are inside my starcleaner.jar and it is a Slick game. And I also followed Kappa's tutorial on ninjacave to create Slick2D applets.

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #6 - Posted 2011-11-21 13:04:19 »

I agree with pitbuller. Signing your own jars is not required. The LWJGL jars are signed and that's sufficient.
It must be a different problem.
My "StarCleaner" game runs as an applet and I didn't sign a single jar file. All resources (images, sheets, etc.) are inside my starcleaner.jar and it is a Slick game. And I also followed Kappa's tutorial on ninjacave to create Slick2D applets.

How did you access the resources?

Thanks for the replies guys. I will try to use the forward slash, and we will see where that goes.

Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #7 - Posted 2011-11-21 13:28:55 »

You are trying to load a resource as a file from the filesystem. Applets are not allowed to do this unless the entire codebase is signed with all permissions granted. You probably actually want to load your resource from one of the applet jars.

Cas Smiley

Offline thaaks

Junior Member


Medals: 1
Projects: 1



« Reply #8 - Posted 2011-11-21 14:14:41 »

I agree with pitbuller. Signing your own jars is not required. The LWJGL jars are signed and that's sufficient.
It must be a different problem.
My "StarCleaner" game runs as an applet and I didn't sign a single jar file. All resources (images, sheets, etc.) are inside my starcleaner.jar and it is a Slick game. And I also followed Kappa's tutorial on ninjacave to create Slick2D applets.

How did you access the resources?

Thanks for the replies guys. I will try to use the forward slash, and we will see where that goes.
StarCleaner relies on some ResourceManager we built as part of MarteEngine. But inside it uses the standard Slick constructors like new Image("relativeResourcepath").
No magic at all except what's happening inside Slick.
All resources are part of the jar of course.

If that's the case for you, something like this should work:
1  
Image background = new Image("res/background.png");


Feel free to browse our MarteEngine source code, the StarCleaner source code is also part of Marte (test/it/marteEngine/game/StarCleaner).

Hope that helps a bit and cheers,
Tommy


Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #9 - Posted 2011-11-21 22:05:15 »

I agree with pitbuller. Signing your own jars is not required. The LWJGL jars are signed and that's sufficient.
It must be a different problem.
My "StarCleaner" game runs as an applet and I didn't sign a single jar file. All resources (images, sheets, etc.) are inside my starcleaner.jar and it is a Slick game. And I also followed Kappa's tutorial on ninjacave to create Slick2D applets.

How did you access the resources?

Thanks for the replies guys. I will try to use the forward slash, and we will see where that goes.
StarCleaner relies on some ResourceManager we built as part of MarteEngine. But inside it uses the standard Slick constructors like new Image("relativeResourcepath").
No magic at all except what's happening inside Slick.
All resources are part of the jar of course.

If that's the case for you, something like this should work:
1  
Image background = new Image("res/background.png");


Feel free to browse our MarteEngine source code, the StarCleaner source code is also part of Marte (test/it/marteEngine/game/StarCleaner).

Hope that helps a bit and cheers,
Tommy

It looks like you did it with a stream some places, and with a filesystem others. I can't build your game though, so I can't check the "file" instance you initialize Images with. Sad

You are trying to load a resource as a file from the filesystem. Applets are not allowed to do this unless the entire codebase is signed with all permissions granted. You probably actually want to load your resource from one of the applet jars.

Cas Smiley

How would this be done?
I only see Image can be initialized the following ways, in Slick:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
Image() 
Image(Image other)
Image(ImageData data)
Image(ImageData data, int f)
Image(java.io.InputStream in, java.lang.String ref, boolean flipped)
Image(java.io.InputStream in, java.lang.String ref, boolean flipped, int filter)
Image(int width, int height)
Image(java.lang.String ref)
Image(java.lang.String ref, boolean flipped)
Image(java.lang.String ref, boolean flipped, int filter)
Image(java.lang.String ref, boolean flipped, int f, Color transparent)
Image(java.lang.String ref, Color trans)
Image(Texture texture)

I cant even seem to get away with the input stream from class.getResourceAsStream(), nor the URL class.getResource()

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #10 - Posted 2011-11-21 22:27:42 »

You need to use Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);

Cas Smiley

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #11 - Posted 2011-11-21 22:35:43 »

You need to use Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);

Cas Smiley

That is still as a stream, and in Slick, I can't create the image from that  Clueless

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #12 - Posted 2011-11-21 23:42:47 »

Isn't there a constructor that takes an InputStream? Wink

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #13 - Posted 2011-11-21 23:45:39 »

Isn't there a constructor that takes an InputStream? Wink

I can't even get that constructor to work, because it also takes a string and a bool.  Emo

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #14 - Posted 2011-11-21 23:55:27 »

new Image(myInputStream, "path/to/file", false);

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #15 - Posted 2011-11-22 00:56:26 »

new Image(myInputStream, "path/to/file", false);

So you suggest a new InputStream()?

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #16 - Posted 2011-11-22 01:32:01 »

No I'm suggesting you give it the same path you gave getResourceAsStream(String):

1  
2  
String resource = "path/to/file";
new Image(Thread.currentThread().getContextClassLoader().getResourceAsStream(resource),resource,false);

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #17 - Posted 2011-11-22 02:12:00 »

No I'm suggesting you give it the same path you gave getResourceAsStream(String):

1  
2  
String resource = "path/to/file";
new Image(Thread.currentThread().getContextClassLoader().getResourceAsStream(resource),resource,false);


1  
background = new Image(Thread.currentThread().getContextClassLoader().getResourceAsStream("/res/background.png"), "/res/background.png", false);

Like this?

It outputs these:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
Mon Nov 21 20:11:04 CST 2011 ERROR:Stream closed
java.io.IOException: Stream closed
   at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
   at java.io.BufferedInputStream.available(Unknown Source)
   at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:53)
   at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
   at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:277)
   at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:231)
   at org.newdawn.slick.Image.load(Image.java:422)
   at org.newdawn.slick.Image.<init>(Image.java:269)
   at org.newdawn.slick.Image.<init>(Image.java:256)
   at com.javadaemon.skrollr.util.ResourceManager.initGraphics(ResourceManager.java:135)
   at com.javadaemon.skrollr.util.ResourceManager.init(ResourceManager.java:42)
   at com.javadaemon.skrollr.util.ResourceManager.<init>(ResourceManager.java:38)
   at com.javadaemon.skrollr.util.ResourceManager.getRessourceManager(ResourceManager.java:31)
   at com.javadaemon.skrollr.GameMain.init(GameMain.java:45)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.javadaemon.skrollr.GameMain.main(GameMain.java:77)
Mon Nov 21 20:11:04 CST 2011 ERROR:Failed to load image from: /res/tileset.png
org.newdawn.slick.SlickException: Failed to load image from: /res/tileset.png
   at org.newdawn.slick.Image.load(Image.java:425)
   at org.newdawn.slick.Image.<init>(Image.java:269)
   at org.newdawn.slick.Image.<init>(Image.java:256)
   at com.javadaemon.skrollr.util.ResourceManager.initGraphics(ResourceManager.java:135)
   at com.javadaemon.skrollr.util.ResourceManager.init(ResourceManager.java:42)
   at com.javadaemon.skrollr.util.ResourceManager.<init>(ResourceManager.java:38)
   at com.javadaemon.skrollr.util.ResourceManager.getRessourceManager(ResourceManager.java:31)
   at com.javadaemon.skrollr.GameMain.init(GameMain.java:45)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.javadaemon.skrollr.GameMain.main(GameMain.java:77)
Caused by: java.io.IOException: Stream closed
   at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
   at java.io.BufferedInputStream.available(Unknown Source)
   at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:53)
   at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
   at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:277)
   at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:231)
   at org.newdawn.slick.Image.load(Image.java:422)
   ... 10 more
 

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #18 - Posted 2011-11-22 02:34:55 »

Hmmm why was the stream closed?

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #19 - Posted 2011-11-22 02:36:03 »

Hmmm why was the stream closed?

This is what I'm doing:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
private void initGraphics() throws SlickException {
      // Prepare the sprite sheet for use
     Image tilesheet1 = new Image(Thread.currentThread().getContextClassLoader().getResourceAsStream("/res/tileset.png"), "/res/tileset.png", false);
      tilesheet = new SpriteSheet(tilesheet1, TILE_WIDTH, TILE_HEIGHT);
     
      Image charsheet1 = new Image(Thread.currentThread().getContextClassLoader().getResourceAsStream("/res/actors/spritesheet.png"), "/res/actors/spritesheet.png", false);
      charsheet = new SpriteSheet(tilesheet1, 16, 24);
     
      // Create animations
     charAnimations = new HashMap<CHARANIM, Animation>();
      for (CHARANIM animationEnum : CHARANIM.values()) {
         int numberOfFrames = animationEnum.frames.length;
         Image[] frames = new Image[numberOfFrames];
         for (int i = 0; i < numberOfFrames; i++) {
            CHAR_IMAGE frameReference = animationEnum.frames[i];
            frames[i] = charsheet.getSubImage(frameReference.getX(), frameReference.getY())
            .getFlippedCopy(animationEnum.flipHorizontal, false);
         }

         Animation animation = new Animation(frames, animationEnum.length);
         animation.setPingPong(animationEnum.pingpong);
         charAnimations.put(animationEnum, animation);
      }
     
      // Set up animation sets
     animationSets = new HashMap<ANIMATION_SET, AnimationSet>();
      AnimationSet animSet = new AnimationSet();
      animSet.addAnimation(DIRECTION.RIGHT.getID() | ANIMATION_STATE.STAND.getID(),
            CHARANIM.CHAR_STAND_RIGHT);
      animSet.addAnimation(DIRECTION.LEFT.getID() | ANIMATION_STATE.STAND.getID(),
            CHARANIM.CHAR_STAND_LEFT);
      animSet.addAnimation(DIRECTION.RIGHT.getID() | ANIMATION_STATE.WALK.getID(),
            CHARANIM.CHAR_WALK_RIGHT);
      animSet.addAnimation(DIRECTION.LEFT.getID() | ANIMATION_STATE.WALK.getID(),
            CHARANIM.CHAR_WALK_LEFT);
      animSet.addAnimation(DIRECTION.RIGHT.getID() | ANIMATION_STATE.JUMP.getID(),
            CHARANIM.CHAR_JUMP_RIGHT);
      animSet.addAnimation(DIRECTION.LEFT.getID() | ANIMATION_STATE.JUMP.getID(),
            CHARANIM.CHAR_JUMP_LEFT);
     
      animationSets.put(ANIMATION_SET.GRAY_GUY, animSet);
     
      background = new Image(Thread.currentThread().getContextClassLoader().getResourceAsStream("/res/background.png"), "/res/background.png", false);
      background.setFilter(Image.FILTER_NEAREST);
   }

.and this is what happening:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
Mon Nov 21 20:35:52 CST 2011 INFO:Slick Build #274
Mon Nov 21 20:35:52 CST 2011 INFO:LWJGL Version: 2.7.1
Mon Nov 21 20:35:52 CST 2011 INFO:OriginalDisplayMode: 1366 x 768 x 32 @60Hz
Mon Nov 21 20:35:52 CST 2011 INFO:TargetDisplayMode: 600 x 400 x 0 @0Hz
Mon Nov 21 20:35:52 CST 2011 INFO:Starting display 600x400
Mon Nov 21 20:35:52 CST 2011 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 Nov 21 20:35:52 CST 2011 INFO:Found 2 controllers
Mon Nov 21 20:35:52 CST 2011 INFO:0 : Razer Mamba
Mon Nov 21 20:35:52 CST 2011 INFO:1 : Razer Mamba
Mon Nov 21 20:35:52 CST 2011 ERROR:Stream closed
java.io.IOException: Stream closed
   at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
   at java.io.BufferedInputStream.available(Unknown Source)
   at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:53)
   at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
   at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:277)
   at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:231)
   at org.newdawn.slick.Image.load(Image.java:422)
   at org.newdawn.slick.Image.<init>(Image.java:269)
   at org.newdawn.slick.Image.<init>(Image.java:256)
   at com.javadaemon.skrollr.util.ResourceManager.initGraphics(ResourceManager.java:135)
   at com.javadaemon.skrollr.util.ResourceManager.init(ResourceManager.java:42)
   at com.javadaemon.skrollr.util.ResourceManager.<init>(ResourceManager.java:38)
   at com.javadaemon.skrollr.util.ResourceManager.getRessourceManager(ResourceManager.java:31)
   at com.javadaemon.skrollr.GameMain.init(GameMain.java:45)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.javadaemon.skrollr.GameMain.main(GameMain.java:77)
Mon Nov 21 20:35:52 CST 2011 ERROR:Failed to load image from: /res/tileset.png
org.newdawn.slick.SlickException: Failed to load image from: /res/tileset.png
   at org.newdawn.slick.Image.load(Image.java:425)
   at org.newdawn.slick.Image.<init>(Image.java:269)
   at org.newdawn.slick.Image.<init>(Image.java:256)
   at com.javadaemon.skrollr.util.ResourceManager.initGraphics(ResourceManager.java:135)
   at com.javadaemon.skrollr.util.ResourceManager.init(ResourceManager.java:42)
   at com.javadaemon.skrollr.util.ResourceManager.<init>(ResourceManager.java:38)
   at com.javadaemon.skrollr.util.ResourceManager.getRessourceManager(ResourceManager.java:31)
   at com.javadaemon.skrollr.GameMain.init(GameMain.java:45)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.javadaemon.skrollr.GameMain.main(GameMain.java:77)
Caused by: java.io.IOException: Stream closed
   at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
   at java.io.BufferedInputStream.available(Unknown Source)
   at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:53)
   at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
   at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:277)
   at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:231)
   at org.newdawn.slick.Image.load(Image.java:422)
   ... 10 more

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #20 - Posted 2011-11-22 03:00:52 »

Well I'm clueless as to why it is getting closed. The good thing is that getResourceAsStream(String) doesn't return null, which means the resource was found. Now this hiccup is quite puzzling :S

Offline BoBear2681

JGO Coder


Medals: 18



« Reply #21 - Posted 2011-11-22 03:02:59 »

BufferedInputStream will throw an IOException with message "Stream closed" if you pass it null as its constructor argument.  Looks like under the covers, Slick is using BufferedInputStream, likely on the stream you pass it, so I'm still betting you're giving the wrong path to your resource and thus getting a null value for the stream.
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #22 - Posted 2011-11-22 03:05:19 »

BufferedInputStream will throw an IOException with message "Stream closed" if you pass it null as its constructor argument.  Looks like under the covers, Slick is using BufferedInputStream, likely on the stream you pass it, so I'm still betting you're giving the wrong path to your resource.

Pretty sure I'm not. It works when initializing an image passing the same path. Tried both as applet, and in my environment. Neither works - they both close  Clueless anything I could try?

Offline BoBear2681

JGO Coder


Medals: 18



« Reply #23 - Posted 2011-11-22 03:18:02 »

Grab the Slick source and run in a debugger?

BufferdInputStream.getInIfOpen() throws that Exception when the wrapped InputStream is null, so I'm still not convinced you're giving it the right path.  Smiley  What is printed when you do this?

1  
System.out.println(Thread.currentThread().getContextClassLoader().getResourceAsStream("/res/tileset.png"));


Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #24 - Posted 2011-11-22 03:35:23 »

Grab the Slick source and run in a debugger?

BufferdInputStream.getInIfOpen() throws that Exception when the wrapped InputStream is null, so I'm still not convinced you're giving it the right path.  Smiley  What is printed when you do this?

1  
System.out.println(Thread.currentThread().getContextClassLoader().getResourceAsStream("/res/tileset.png"));




Nothing is printed  persecutioncomplex

This is getting a little.. meh.. Just checked out kevglass' Fizzy Bricks, and he loads
1  
this.cols[0] = new Image("res/blue.png");

and the file-system in his jar looks identical to mine. However, when I try to run something that just loads this one picture, using the way above, it still does not work Shocked

Offline gbeebe

Senior Member


Medals: 5
Projects: 1



« Reply #25 - Posted 2011-11-22 03:47:49 »

Can you run Fizzy Bricks without an error?

[edit]  and wouldn't the beginning "/" denote the root of the file system instead of the directory where the applet is?
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #26 - Posted 2011-11-22 03:53:40 »

Can you run Fizzy Bricks without an error?

[edit]  and wouldn't the beginning "/" denote the root of the file system instead of the directory where the applet is?

Yes. Not my build though, but I can look inside whats going on.
I tried both with and without the front slash - none work.

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #27 - Posted 2011-11-22 04:40:54 »

If it was null, "null" would be printed. If it wasn't null, you would get java.io.InputStream@<hashcode>.

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #28 - Posted 2011-11-22 05:10:33 »

If it was null, "null" would be printed. If it wasn't null, you would get java.io.InputStream@<hashcode>.

It did not print anything at all. Im definite that the block is executed, but it doesnt print. Can I show you, in some way? I can upload the applet, and you can look at errors/source for yourself if you would like :-)

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #29 - Posted 2011-11-22 05:11:54 »

Sure!

Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

UprightPath (21 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (95 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29

BurntPizza (52 views)
2014-09-07 01:13:42

Longarmx (39 views)
2014-09-07 01:12:14

Longarmx (45 views)
2014-09-07 01:11:22
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!