• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

finding images in netbeans

 
Ranch Hand
Posts: 287
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 15743
368
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 287
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
it's a teeny, tiny, wafer thin ad:
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic