4 Replies - 14220 Views - Last Post: 14 May 2010 - 10:47 PM Rate Topic: -----

#1 zim1985  Icon User is offline

  • Grand Inquisitor
  • member icon

Reputation: 74
  • View blog
  • Posts: 568
  • Joined: 19-February 10

Where to Put Image Resources in Eclipse

Posted 14 May 2010 - 11:02 AM

So I am making a game in Eclipse, but I can't access the image files.

I put it in the src/resources/images folder and access it as such with a getClass().getClassLoader().getResource("resources/images/dog.png")

Where do I need to put the images folder in order to access it? I ran my program in BlueJ and it worked exactly as I wanted it to.
Is This A Good Question/Topic? 0
  • +

Replies To: Where to Put Image Resources in Eclipse

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2694
  • View blog
  • Posts: 11,360
  • Joined: 20-September 08

Re: Where to Put Image Resources in Eclipse

Posted 14 May 2010 - 11:49 AM

Try

URL url = getClass().getResource("/resources/images/dog.png")

Was This Post Helpful? 0
  • +
  • -

#3 YasuoDancez  Icon User is offline

  • D.I.C Head

Reputation: 20
  • View blog
  • Posts: 135
  • Joined: 30-September 09

Re: Where to Put Image Resources in Eclipse

Posted 14 May 2010 - 08:04 PM

Try that and also the way that i have structured my folders is inside of Eclipse i create the folders in my package ( default package is the default one ) then i drag and drop or copy and paste my images, sounds , or what ever media into the proper related folders. Images i use the code that g00se has mentioned to link.
Although, sounds I've been having a trouble with getting to work externally.
Was This Post Helpful? 0
  • +
  • -

#4 Ember  Icon User is offline

  • D.I.C Head

Reputation: 70
  • View blog
  • Posts: 160
  • Joined: 24-April 10

Re: Where to Put Image Resources in Eclipse

Posted 14 May 2010 - 08:14 PM

You should put it in whatever you named your project and it should run.

So if you named a project DIC, go to your workspace and put the folder in the folder directory called DIC. That is where I always put my files for I/O operations and it works like a charm.
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8329
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Where to Put Image Resources in Eclipse

Posted 14 May 2010 - 10:47 PM

Just make sure you do not just copy into whichever directory your files
Use Eclipse "Import file system" tool to do so to Eclipse project will know about the files existence
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1