InsaneCoder
InsaneCoder

Reputation: 8288

Java: image not loading in Eclipse

I searched a lot on Stack Overflow and followed the answer given here. But I am still getting IllegalArgumentException : input==null! for the following lines:

BufferedImage image=ImageIO.read(this.getClass().getResource("/images/bg.jpg"));    
ImageIcon logo=new ImageIcon(ImageIO.read(this.getClass().getResource("/images/tucan.png")));

I tried everything but still no success. My directory structure is this:
News -->res-->images-->bg.jpg,tucan.png

enter image description here

Upvotes: 0

Views: 5417

Answers (1)

Neet
Neet

Reputation: 4057

You have to add your res folder to the list of source folders.

Right Click -> Build Path -> Use as source folder

If you don't, then Eclipse won't copy the folder into the output folder and you can't access them in the way you tried to do.

Upvotes: 5

Related Questions