Difficulty using BufferedImage in Eclipse -


i have stored image in resource folder 'images':

src

-com.program

-images

in program use

bufferedimage image =imageio.read(getclass().getresourceasstream("/myimage.png")); 

to import image.

this works fine. however, if change name of image @ source(say myimage1.png) , try execute

bufferedimage image =imageio.read(getclass().getresourceasstream("/myimage1.png")); 

i input==null. i've been try work while , tried various suggestions on other threads. ideas? thanks!

the problem likely:

the image in src folder inside project, when program runs, runs folder containing compiled classes. folder did not contain png, input == null exception (getclass().getresourceasstream(...) returns null when resources cannot resolved).

to make work, need mark images folder resource folder (using eclipse, maven or favorite build tool), , make sure contents of folder on class path when program run.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -