loading an image from a package in Java (JFrame)

Posted by Shahar Kazaz on Stack Overflow See other posts from Stack Overflow or by Shahar Kazaz
Published on 2013-06-26T10:11:53Z Indexed on 2013/06/26 10:21 UTC
Read the original article Hit count: 164

Filed under:
|
|

i'm having a problem loading an image from a package i created in the project that was set to contain images, i have to write the whole picture location in the computer instead of just the package that contains it. i've tried several things but nothing seams to work... where is the command i use to load the image :

    searchBar = ImageIO.read(new File("C:\\Users\\ASUS\\Documents\\NetBeansProjects\\Project\\src\\Images\\search.jpg"));

"Images" is a package in my project , this works, but when i try loading the image without the "C:\..." only with the "\Images..." it doesn't , so i have to change it every time i open this project in another computer. hopefully one of u has the answer for me , thanks in advance for any answer :)

© Stack Overflow or respective owner

Related posts about java

Related posts about image