Hello Guest

Need help to get webstart working with resources.

  • 1 Replies
  • 5444 Views
Need help to get webstart working with resources.
« on: June 21, 2011, 11:46:03 »
Hi guys. I noticed a helpful webstart thread on the front page however it didn't quite help me so I'll post this one.

I'm trying to get my first game type thing working with webstart.

This is the first time i've attempted to run something outside of netBeans. My program appears to just open and then shut straight away when I use webstart.

I'm quite sure i've got the security signatures, jar files and jnlp file right. The problem is most probably loading resources.

fManager.loadSectorTypes("sectors01.txt");
        fManager.loadLevel("level2.txt");
        texture[0] = TextureLoader.getTexture("PNG", new FileInputStream("stonewall02.png"));
        texture[1] = TextureLoader.getTexture("PNG", new FileInputStream("stonefloor01.png"));

Those are examples of the lines that load the data in my program.. Worked fine in netbeans with the files in the project folder.

What do I change these lines to, and where do I put them in relation to my jar files to get it working properly?

I've read that it could be Resources.class.getClassLoader().getResource("path/to/logo.png"); however i'm not sure where the Resources object is.

Thanks for your help!

Re: Need help to get webstart working with resources.
« Reply #1 on: July 08, 2011, 23:35:56 »
you are on the right track.

here is how I load a texture right now in an applet:

TextureLoader.getTexture("PNG", Sprite.class.getClassLoader().getResourceAsStream(imagepath) );

imagepath is a string path relative to the "src" directory.

I was having that problem last week myself :)

If you are still having problems, make sure the path doesnt start with a slash or anything like that. So something like

"/myfolder/myasset.png"

should be

"myfolder/myasset.png"