• Post Reply Bookmark Topic Watch Topic
  • New Topic

finding images in netbeans  RSS feed

 
Ranch Hand
Posts: 260
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've just loaded up netbeans and something called Inno 5 and Wix.
I'm wanting to create an exe for my game (a Java application).
Everything compiles but then it fails when it can't find any images.
I'd read that I should put them in a folder called "resources" at the same level as the "src" folder.

I've tried:
but neither worked. I have a similar problem for loading up wav sounds. Can offer any advice?
Thank you
Mike
 
Saloon Keeper
Posts: 7993
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mich.

you should position your resources relative to your application's class path. You can either put your resources in the src folder, or put them in a separate folder (like res, resources, img, images, etc...) and then add the folder to your application's class path. You can also store them in a jar and add the jar to the class path.

getResource("ship.png") will look for the resource in com/example/ship.png. If you want the resources at the top, you should look for "/ship.png" instead.
 
Mich Robinson
Ranch Hand
Posts: 260
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, it's working now.
I do have other issues (trying to pass java directives ie java2d.nodraw=true) but it's probably best I start a new thread rather than confuse this one.
Mike
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!