Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Resource picture not found[SOLVED]  (Read 290 times)
0 Members and 1 Guest are viewing this topic.
Offline neuronich

JGO n00b
*

Posts: 21
Medals: 5



« on: 2012-01-16 18:39:07 »

Hello everyone!
I have searched a lot but still don't manage to find the resource file icon.png getting ImageIO exception!
1  
Sprite sprite = new Sprite(ImageIO.read(Game.class.getResourceAsStream("/icons.png")));

where
1  
2  
3  
public Sprite(BufferedImage image) {
      "something"
      }


Here is how my package tree looks like.
package--->src->Game.java
            |->res->icons.png
*I have tried deleting /
*I have tried adding source lookup path
*I have tried putting the full c:/games/..../icons.png path
Thank you in advance!
Offline Cero

JGO Neuromancer
****

Posts: 1050
Medals: 18



« Reply #1 on: 2012-01-16 20:39:54 »

well ist not
1  
"/icons.png"

but
1  
"res/icons.png"

Offline ra4king

JGO Kernel
*****

Posts: 3160
Medals: 196


I'm the King!


« Reply #2 on: 2012-01-16 22:49:41 »

It will never find the "res" folder because it's not on the build path. The easiest way is to just move the "res" folder to under "src" and then doing "/res/icons.png".

Games published by our own members! Go get 'em!
Offline ReBirth

JGO Wizard
****

Posts: 1279
Medals: 19



« Reply #3 on: 2012-01-16 23:34:55 »

I always put "res" same place as "bin" and "src" then call "res/blah" Smiley

Follow me, your mastah, on TWITTAH!
Offline ra4king

JGO Kernel
*****

Posts: 3160
Medals: 196


I'm the King!


« Reply #4 on: 2012-01-16 23:40:19 »

To be able to do that, you need to right click "res" and choose Build Path -> Use As Source Folder. But it's easier for exporting to just put it under "src".

Offline neuronich

JGO n00b
*

Posts: 21
Medals: 5



« Reply #5 on: 2012-01-17 14:10:41 »

Yes. That's what I missed. (Building the path). Thank you very much! Smiley
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.137 seconds with 20 queries.